I have a series of webdropdown controls on my page which utilize Javascript and server-side methods to dynamically add/remove values from the lists. For example, if I have 3 webdropdown controls, each has a list of numbers 1-10. After the user picks number 1 in the first webdropdown, number 1 must be removed from the other two webdropdown lists (since it's already used). If the user picks number 2 in the second webdropdown, number 2 must be removed from the first and third webdropdown lists.
My question is...after the user picks a number, the page does a postback and as the code is stripping off the number from each dropdownlist (box), that dropdownlist automatically opens to show the updated list. Is there a property/method that can control this and always keep the dropdownlist closed unless the user explicitly clicks on the arrow to open it?Thank you,Chris
Hi Chris,
Thanks for your reply. Glad that your issue has been resolved.
Please do not hesitate to contact me if I can be of assistance.
Hi Petar,I appreciate the follow up. I ended up rewriting a portion of my page to use more server-side code to handle the logic. As a bonus, the "open" display of the webdropdown control does not happen anymore. But, this is a good tidbit to know for next time! :-)Thank you,Chris
Please feel free to contact me if you are still experiencing any issues.
Apologies for the delayed response.
After further researching the matter, it seems that when loading items in the dropdown dynamically, the DropDownOpening event has to be cancelled after the items have been loaded in order to acheive the desired functionality. Below is some sample javascript for such a scenario:
Please let me know if this helps.
If I'm understanding correctly, I added the <ClientEvents> tag to my webdropdown:<ig:WebDropDown ID="ddlSCP1" runat="server" Width="350" AutoPostBack="true"SelectedValue='<%# DataBinder.Eval(Container.DataItem,"sprac1")%>OnItemsRequested="ddlSCP1_OnItemsRequested"OnPreRender="ddlSCP1_OnPreRender"OnDataBound="ddlSCP1_OnDataBound" Visible="true" EnablePaging="false"PageSize="10" EnableRenderingAnchors="false" ForeColor="Black"OnSelectionChanged="ddlSCP1_OnSelectionChanged"EnableClosingDropDownOnSelect="true"><ClientEvents Initialize="ddlSCP1_closeDropDown" /><DropDownItemBinding TextField="dept_desc" ValueField="dept_code" /></ig:WebDropDown>The Initialize event calls this Javascript function:
function ddlSCP1_closeDropDown(sender) { sender.closeDropDown();}As FYI, I also have this Javascript function that runs at page load:function pageLoad(sender, args) { if (_isInitialLoad) { _isInitialLoad = false; var timer_is_on = 0; if (!timer_is_on) { timer_is_on = 1; t = setTimeout("checkddlSNOM5Loaded()", 500); } }}This is the primary function to determine when it's time to execute (other) Javascript that add/removes numbers from the series of webdropdown controls.When my page loads, if the webdropdown has a SelectedValue, the dropdown list (box) opens and stays open until I click somewhere else on the page. Do I need to use the same Initialize function somewhere else so that the webdropdown stays closed after page load and after the Javascript logic completes?Chris