tags:

views:

32

answers:

2

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  A: 

Something like this could do the magic

$('#<%= CheckBox1.ClientID %>').click(function(){
  if ($('#<%= DropDownList2.ClientID %>').attr('disabled') != true)
    $('#<%= DropDownList2.ClientID %>').attr('disabled', true);
  else
    $('#<%= DropDownList2.ClientID %>').attr('disabled', false);
})
Claudio Redi
A: 
$("#'<%=CheckBoxId.ClientID %>'").click(function(){
    if( $("#'<%=CheckBoxId.ClientID %>'").attr('checked'))
       $("#'<%=DropDownListID.ClientID %>'").attr('disabled', true);
    else
       $("#'<%=DropDownListID.ClientID %>'").attr('disabled', false);
 });
Azhar