PDA

View Full Version : [FIXED] [V0.7.0] Bug with DatePicker



Jurke
Oct 01, 2008, 9:18 AM
Hi
I noticed a annoying bug when using the datepicker and a ajaxevent. This is how it goes:
The page must have scrollbars, so that its is able to scroll up and down.
1. Select a date in the picker
2. Excecute an ajax event
Then the page scrolls up to the datepicker at the selected date. This only happens when a date is selected in the picker. Here comes a code example:



public partial class Test_Default : System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{


base.OnInit(e);


for (int i = 0; i < 100; i++)
{
pnlMain.Html += "<br>row";
}


}


protected void Test(object sender, AjaxEventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}
}




<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Test</title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ScriptManager ID="ScriptManager2" runat="server" />
<ext:DatePicker ID="DatePicker1" runat="server"/>

<ext:Panel Id="pnlMain" runat="server" Collapsible="false" BodyBorder="false" Border="false" Header="false" AutoScroll="True" />
<ext:Label ID="Label1" runat="server" />

<ext:Button ID="Button1" runat="server" Text="Button">
<AjaxEvents><Click OnEvent="Test"><EventMask ShowMask="true" Msg="Loading"/></Click></AjaxEvents>
</ext:Button>

</form>
</body>
</html>





Best regards
Mikael Jürke

geoffrey.mcgill
Oct 01, 2008, 1:58 PM
Hi Mikael,

We're investigating this issue. Thanks for providing the code sample

Jurke
Oct 05, 2008, 8:18 AM
Hi
Sorry to bother you again on this issue, Im just wondering what the status is on this bug. My program is really annoying to use with this bug.

Best regards
Mikael Jürke

Vladimir
Oct 05, 2008, 8:55 AM
Hi Mikael,

This bug was fixed. Please update from the SVN and recompile code.

P.S. Small tip:



for (int i = 0; i < 100; i++)
{
pnlMain.Html += "<br>row";
}


Avoid similar constructions (even in demo purposes) as at their usage memory consumption grows as avalanche. Use StringBuilder for concatenation strings in loop. And don't forget to wrap constructions to if(!Ext.IsAjaxRequest) if you don't want to update Coolite controls during AjaxEvent. For example, I changed your example as below:



protected override void OnInit(EventArgs e)
{
base.OnInit(e);

if (!Ext.IsAjaxRequest)
{
StringBuilder sb = new StringBuilder(512);
for (int i = 0; i < 100; i++)
{
sb.Append("<br>row");
}

pnlMain.Html = sb.ToString();
}
}


Please let me know if the fix doesn't work for you

Jurke
Oct 05, 2008, 11:15 AM
Thanks! it works great for me! exellect.

Thanks for you tip. is this as bad as my fist example?



string strTest;
for (int i = 0; i < 100; i++)
{
test += "strTest";
}

pnlMain.Html = strTest


Because I almost never know how big the contet of the string will be in advance

Best regards
Mikael

Vladimir
Oct 05, 2008, 12:00 PM
If you don't know size of content then better use StringBuilder. You can concatenate two or three string using + operator. But in loop need use StringBuilder (http://blog.briandicroce.com/2008/02/04/stringbuilder-vs-string-performance-in-net/)

Hope this help