Welcome Guest Search | Active Topics | Sign In | Register

Error using EO DatePicker with JQuery UI.Tabs Options
Simon
Posted: Sunday, September 21, 2008 5:32:28 PM
Rank: Newbie
Groups: Member

Joined: 9/21/2008
Posts: 4
Hi,
We are just trialling your product and all works well apart from any of our pages that use the jquery ui tab control with ajax features

Javascript error: Error: Unknown runtime error, and when debugging breaks on line "_eofi_dz(_eo_o_ctl02_DatePickerIncStart,1,null, 0);"

Must be because the page is loaded asynchronously?

Any help would be cool
eo_support
Posted: Sunday, September 21, 2008 6:34:08 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Loading asynchronously should not be a problem, but as for AJAX, we only officially support ASP.NET AJAX and our own CallbackPanel. However if you can provide more information about the problem, such as the code before and after the error, we should be able to match it with our source code and see what we can find. Also if you can post a page that demonstrates the problem online, we will be happy to take a look and see what we can do.

Thanks!
Simon
Posted: Monday, October 27, 2008 4:26:39 PM
Rank: Newbie
Groups: Member

Joined: 9/21/2008
Posts: 4
Thanks for the reply.
I've posted a sample demo page to illustrate the issue that we have.
http://www.macquarieview.com/DatePicker/WorkingPage.aspx.

The not working page has a web page witht the control on it. (PageLoader.aspx)
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div id="divPlaceHolder" runat="server">

</div>
<eo:DatePicker ID="DatePickerIncStart" runat="server" DisabledDates="" PickerFormat="dd/MM/yyyy hh:mm:ss tt"
SelectedDates="" TitleLeftArrowImageUrl="DefaultSubMenuIconRTL" TitleRightArrowHtml=""
TitleRightArrowImageUrl="DefaultSubMenuIcon" Width="100px" DayCellHeight="16"
DayCellSpacing="1" DayCellWidth="25" Visible="false">
<CalendarStyle CssText="background-color:white;color:black;" />
</eo:DatePicker>
</form>
</body>
</html>

The page has the jquery ui tabs control that references this page. (NotWorking.aspx)
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script src="jquery.source.js" type="text/javascript"></script>
<script src="ui.core.js" type="text/javascript"></script>
<script src="ui.tabs.js" type="text/javascript"></script>
<style type="text/css">
.tab_container{ padding: 0 0 0 5px; }
ul.tabs { }
ul.tabs li {float: left; width: 90px; background-color:blue; margin: 0 1px 0 0;}
ul.tabs li.ui-tabs-selected {background-color:blue; font-weight: bold;}
ul.tabs li.ui-tabs-disabled {opacity:.4;filter: alpha(opacity=40);background-color:blue; font-weight: bold;}
ul.tabs li.hover {background-color:blue;}
ul.tabs li a { display: block; height: 19px; padding: 5px 0 0 5px; color: #fff; text-decoration: none;}
ul.tabs li a:hover {color: #fff;}
.ui-tabs-hide {display: none;}
.tab_content{padding: 15px 15px 5px 5px;}
</style>

</head>
<body>
<form id="form1" runat="server">
<div>
<div id="container-1" class="tab_container">
<ul class="tabs">
<li><a href="PageLoader.aspx">Tab 1</a></li>
<li><a href="AnotherTest.aspx">Tab 2</a></li>
<li><a href="Tab3.aspx">Tab 3</a></li>
</ul>
</div>
<br />
<br />
<br />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/WorkingPage.aspx">Test Working Page</asp:HyperLink></div>
<script type="text/javascript">
$('#container-1 > ul').tabs();
</script>
</form>
</body>
</html>


Any ideas would be great - so we can purchase, otherwise we'll have to look at other alternatives as we're already using the tab controls

Thanks
eo_support
Posted: Monday, October 27, 2008 4:45:44 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi Simon,

Thanks for the code. We will look into it and hopefully can provide you a solution as early as tomorrow.

Thanks!
eo_support
Posted: Monday, October 27, 2008 8:51:27 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

We have looked into the issue and found the root of the problem to be the way JQuery loads the tab page (PageLoader.aspx) into the host page (NotWorking.aspx). Detailed analysis about this issue and a few possible solutions are provided below. The issue can affect any ASP.NET page and is not particular related to our product.

How JQuery Tab works

JQuery tab works by AJAX loading the tab page (in your case PageLoader.aspx), taking the HTML output of that page, "clean it up" and then "place" the cleaned up output into your tab container in your host page (in your case "container-1" in NotWorking.aspx). An example:

Step 1: Your host page is loaded

Code: HTML/ASPX
<form id="form1">
    ....
    <div id="container-1" class="tab_container">
    ....
    </div>
    ....
</form>

Step 2: The tab content page is loaded

Code: HTML/ASPX
<html>
<body>
    <form id="form1">
        tab page contents....
    </form>
</body>
</html>


Step 3: "Clean up" tab content page output. Note the code actually takes a string input and returns an array of DHTML elements. Here we show the "cleaned up" HTML only for demonstration purpose:

Code: HTML/ASPX
<form id="form1">
   tab page contents....
</form>


Step 4: "Place" the cleaned up HTML into the container DIV:

Code: HTML/ASPX
<form id="form1">
    ....
    <div id="container-1" class="tab_container">
        <form id="form1">
            tab page contents....
        </form>
    </div>
    ....
</form>


Now the contents of PageLoader.aspx appears inside NotWorking.aspx as a tab (causing JavaScript error though).

The Problem

As step 4 demonstrates, the final HTML generated by JQuery Tab created nested form elements (even with the same ID!). This is not allowed in HTML and it seriously confused browser. This is the root cause of all sorts of mysterious JavaScript errors when you use JQuery Tabs with ASP.NET.

The Solution

In order to solve the problem, nested form elements must be avoided. That means you need to either remove the form element in your host page (NonWorking.aspx) or in your tab page (PageLoader.aspx), or rearrange them so that they do not overlap.

Rearranging them should be the easiest solution. If the host page can be changed to:

Code: HTML/ASPX
<form id="form1">
    ....
</form>    ....
<div id="container-1" class="tab_container">
    ....
</div>


That should solve the problem nice and clean. Note the tab container is no longer inside the form element.

If you can not arrange the form element that way, the you must removing one of the form element. Removing form element in your host page should be rather straight forward --- just remove the form element from the page. That should fix the JavaScript errors. However it can break other code in your page since ASP.NET is so profoundly built on top of HTML forms. Specifically, all input controls in your host page will stop working. For example, if you have a TextBox control in your host page, then it will stop working once you remove the form element. As such removing the form element from your host page can only be a solution for you when you have no other input elements in the page.

Removing form element in your tab page poses the same problem ---- DatePicker itself is an input element. So removing form element would cause that to stop working. In fact DatePicker control throws out an error unless it is being placed inside a form element.

The most effective solution, as our research indicates, seems to be modifying JQuery script so that step 1 and step 2 (see "How JQuery Tab works" section) is not changed, but take the form element out in step 3. This changes the final output in step 4 into:

Code: HTML/ASPX
<form id="form1">
    ....
    <div id="container-1" class="tab_container">
         tab page contents....
    </div>
    ....
</form>


This is valid HTML and should not cause any problem.

Follow these steps to take this approach:

1. Open JQuery.js (or JQuery.source.js in your case) with a text editor;

2. Search for the following code segment:

Code: JavaScript
clean: function( elems, context ) {
   .....
   if ( typeof elem == "string" ) {
       // Fix "XHTML"-style tags in all browsers    
       ....


3. Change it to:

Code: JavaScript
clean: function( elems, context ) {
   .....
   if ( typeof elem == "string" ) {
      // Remove form tags
      elem = elem.replace(/<form[\w\W]*?>/gi, "");
      elem = elem.replace(/<\/form>/gi, "");
            
       // Fix "XHTML"-style tags in all browsers    
       ....


Note the two added lines that removes open and close form tag.

Please keep in mind since this still removes the form element, it would inevitably break the normal ASP.NET page life cycle. Specifically, server events in your tab page will stop working. For example, if you have an ASP.NET Button in PageLoader.aspx, once it is loaded into NonWorking.aspx (which should be working now), the button's server side event handler will no longer be called when you click the button. The first solution (rearranging form elements so that they do not overlap) does not have this issue.

Hope this helps.

Thanks
Simon
Posted: Tuesday, October 28, 2008 1:52:58 PM
Rank: Newbie
Groups: Member

Joined: 9/21/2008
Posts: 4
thanks for the detailed analysis and workarounds - we will be purchasing shortly :)
eo_support
Posted: Tuesday, October 28, 2008 2:24:49 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Good to hear that! Please feel free to let us know if you have any more questions.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.