Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Greeting.
How to enable or disable asp.net DropDownList control using jquery when checking an asp.net checkbox.
So I have I have an asp.net checkbox when I check it I want to enable/disable a DropDownList.
Thank you,
Something like this could do the magic
$('#<%= CheckBox1.ClientID %>').click(function(){ if ($('#<%= DropDownList2.ClientID %>').prop('disabled') != true) $('#<%= DropDownList2.ClientID %>').prop('disabled', true); else $('#<%= DropDownList2.ClientID %>').prop('disabled', false); })
Add a comment
$("#'<%=CheckBoxId.ClientID %>'").click(function(){ if( $("#'<%=CheckBoxId.ClientID %>'").attr('checked')) $("#'<%=DropDownListID.ClientID %>'").attr('disabled', true); else $("#'<%=DropDownListID.ClientID %>'").attr('disabled', false); });
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.