Showing posts with label requests. Show all posts
Showing posts with label requests. Show all posts

Monday, March 26, 2012

Listbox selections to update secondary listbox items

Good Afternoon,

I am extremely new to the Atlas functionality, and am trying to address some customer requests using Atlas. Two listboxes, Category and SubCategory, are initially rendered on the page with all distinct values. My question is how to update the SubCategory listbox when items have been selected in the Category listbox. I have tried to include a parameter for the selection of the SubCategory items, but the list initially is rendered with no items since the parameter value is not assigned.

Any help, insight, or suggestions is greatly appreciated. Also, any suggestions on best practices is also welcome regarding controls utilizing Atlas (for example, using a dataset to populate the listbox versus going directly against the SQL tables).

Thank you,

Erik

Hi,

It sounds like the CascadingDropDown control in this toolkit may be the answer to your questions.

http://atlas.asp.net/atlastoolkit/CascadingDropDown/CascadingDropDown.aspx

Regards


Thank you for the response. Is there any way to utilize a listbox instead of a drop down? Currently, the users can select multiple items from the list.

Hi,

Could you initially populate the subcategory box in the page_load event (when not Page.Ispostback), then have the list updated with a control event parameter on the Category Listbox.

Hope this helps

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

Loading scripts

Ajax controls always load scripts throw ScriptResource.axd. So we hava many requests to the server. I think if there is a possibility to load these scripts together it will be faster page loading. What do you think about it?

Hi,

did you set your application in debug mode? If so then the debug versions of the javascripts will be loaded each time and remember these debug versions are also bigger then their release versions. You can check your settings in the web.config:<compilation> element.

Grz, Kris.


my problem is not in the big debug files. in the release mode I have the same problem: too much requests to the server. I'm interesting of how can I load ajas scripts not partialy.


Solution is simple. In The new ToolKit release we have new feature "ScriptCombining". It is real working. Tomorrow I'll test it in the real project.

But maybe anybody know ho to do it in with old version of toolkit?


Does anybody use new toolkit? I have less requests to the server but page size is bigger with new options.


Hi,

I compared the results, but there is no significant difference in size.