Hi,
I am trying to reset a WebDropDown's currently displayed value using javascript. If the user clicks a checkbox I want to reset the value showing in the webdropdown to the words "Select items". I a using set_currentValue but it does not change what is displayed on the page. Here is my code,
function disableWDD(sender, eventArgs) { if (document.getElementById("<%=chkSrchField.clientID%>").checked) { document.getElementById("<%=wddMyWDD.clientID%>").disabled = true; document.getElementById("<%=wddMyWDD.clientID%>").set_currentValue = "Select items"; It goes through this code but the displayed value does not change to "Select items". What am I doing wrong? Thank you.
Hello ,
Thank you for contacting Infragistics support.
You should use $find instead of document.getElementById in order to access the WebDropDown on the client.
function btn_click() {
var wdd = $find("<%=WebDropDown1.ClientID%>");
wdd.set_currentValue("Select items");
wdd.set_enabled(false);
}
Please refer to the online documentation regarding more information about CSOM of WDD:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1?page=WebDropDown~Infragistics.Web.UI.WebDropDown_members.html
Let me know if you need further assistance regarding this.
Thank you for the prompt reply.
I tried the code you suggested and the disable works perfectly but the value displayed in the drop down still shows the item I selected. It does not change back to “Select items”. When I get back to the server the currecnt value is set to "Select items" and the selecteditems.count is 1. the selecedted.items(0).text has the item i selected from the drop down list. I think I need to clear the selection but I do not see this in the CSOM. How can I reset the value showing in the input box of the webdropdown? Any ideas?
Thank you.
Hello longpond ,
Thank you for the update.
You should use the below syntax:
dropDown.set_currentValue("NEW VALUE", true );
The "true" parameter is passes so that the input field is updated.
If you want to clear the selection please refer to the below post:
http://community.infragistics.com/forums/p/30177/161244.aspx#161244
Let us know if you need further assistance.
That works perfectly! Thank you so much.