Romaopporania
New Member
I am trying to add a client side event to a dropdownlist and I need to access the currently selected Text. I have tried:\[code\]ddl_tech.Attributes.Add("onclick", "document.getElementById('" + chk_techreview.ClientID + "').disabled = this.options[this.selectedIndex].text.Equals(' UNASSIGNED');");\[/code\]and \[code\]ddl_tech.Attributes.Add("onclick", "document.getElementById('" + chk_techreview.ClientID + "').disabled = this.text.Equals(' UNASSIGNED');");\[/code\]Both of which give me runtime errors when the event is fired.Whats the correct way to access this text property client side?I tried this but it does not enable the checkbox...\[code\]ddl_tech.Attributes.Add("onchange", "document.getElementById('" + chk_techreview.ClientID + "').disabled = this.options[this.selectedIndex].text == ' UNASSIGNED';");\[/code\]ANSWER:Well, along with having to use == rather than .Equals, when you set a checkbox.enabled = false on the server side it raps the checkbox in tags and sets it to disabled=true; therefore you must set BOTH the checkbox.disabled = false and checkbox.parentElement.disabled = false; on the client side to enable the checkbox!The solution:\[code\]ddl_tech.Attributes.Add("onchange", "document.getElementById('" + chk_techreview.ClientID + "').parentElement.disabled = (this.options[this.selectedIndex].text == 'UNASSIGNED'); document.getElementById('" + chk_techreview.ClientID + "').disabled = (this.options[this.selectedIndex].text == 'UNASSIGNED');");\[/code\]Thanks for the help!