Showing posts with label version. Show all posts
Showing posts with label version. Show all posts

Monday, March 26, 2012

ListSearch does not preserve ViewState

I just downloaded the latest version of the Toolkit today hoping that the 3 or so issue requests for the ListSearch would have corrected everything.

My problem is that after a item is selected in a DropDownList the and I either hit the tab key or press enter (with the autopostback set on the ddl) the postback occurs (that part was fixed from the last version) but when the page comes back the ddl is reset. It does not contain the item I selected even though enableviewstate is set to true. Does anyone else have this problem or know how to correct it?

Thanks

I've just run a small test and it worked fine for me -- if you change the item simply by clicking, does the selected item remain?

Thanks,

Damian


FWIW if you try enabling the AutoPostBack on the example in the toolkit, then it won't work because the control's contents are always rebound on page load, instead of just once when the page is initially loaded.

Regards,

Damian (ListSearch author)


No it does not, I have tried it both in a update panel and with the controls by themselves (not that that should matter). For my testing I took the listsearch page from the new sample website and just added a label to it. Then in the selectedindexchanged event of the ddl I set the label text to the current datetime just to test the postback funtionality I want to use. As far as I know I have left the ddl and the extender alone with the exception of setting the autopostback.


Hmmm. So is there a way then to cancel the binding of the controls contents on the postback? I'm guessing check the Page.IsPostBack and Page.IsCallBack properties, but where would I do that?

Thanks,

BTW. Below are the pieces of code I am working with.

<script runat="server"> protected override void OnLoad(EventArgs e) { base.OnLoad(e); ListBox1.DataSource = GetWordListText(); ListBox1.DataBind(); DropDownList1.DataSource = GetWordListText(); DropDownList1.DataBind(); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToLongTimeString(); }</script><asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:DropDownList ID="DropDownList1" runat="server" Width="100px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="True" /><asp:Label ID="Label1" runat="server" Text="Label" Width="125px"></asp:Label><ajaxToolkit:ListSearchExtender ID="ListSearchExtender2" runat="server" TargetControlID="DropDownList1" PromptCssClass="ListSearchExtenderPrompt"> </ajaxToolkit:ListSearchExtender> </ContentTemplate></asp:UpdatePanel>

If you do do something like this it should work:

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

if(!IsPostBack ) {
ListBox1.DataSource = GetWordListText();
ListBox1.DataBind();
DropDownList1.DataSource = GetWordListText();
DropDownList1.DataBind();

}
}


Thanks Damian, that did it. Also, thanks so much for you work with the toolkit.

Wednesday, March 21, 2012

Localized Calendar

I need use a localized version of CalendarExtender, but it's not possible to change the format of today because the javascript function _performLayout set this._today.innerHTML = "Today: " + todaysDate.format("MMMM d, yyyy");

Yes, it's easy replace this line, but all the contents are localized, why not this??

Hi there will be a fix for this in the next realease of the control toolkit due 28 feb.

This has been reported as workitem 7577 more info onhttp://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=7577

More info about bug fixes in the 10228 release can be found herehttp://www.codeplex.com/AtlasControlToolkit/Release/ProjectReleases.aspx?ReleaseId=1425

Hope this helps!