6

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,

2 Answers 2

7

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);
})
Sign up to request clarification or add additional context in comments.

Comments

1
$("#'<%=CheckBoxId.ClientID %>'").click(function(){
    if( $("#'<%=CheckBoxId.ClientID %>'").attr('checked'))
       $("#'<%=DropDownListID.ClientID %>'").attr('disabled', true);
    else
       $("#'<%=DropDownListID.ClientID %>'").attr('disabled', false);
 });

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.