Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

enable asp.net DropDownList control using jquery

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,

like image 772
Eyla Avatar asked Aug 20 '10 15:08

Eyla


2 Answers

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);
})
like image 54
Claudio Redi Avatar answered Sep 29 '22 19:09

Claudio Redi


$("#'<%=CheckBoxId.ClientID %>'").click(function(){
    if( $("#'<%=CheckBoxId.ClientID %>'").attr('checked'))
       $("#'<%=DropDownListID.ClientID %>'").attr('disabled', true);
    else
       $("#'<%=DropDownListID.ClientID %>'").attr('disabled', false);
 });
like image 39
Azhar Avatar answered Sep 29 '22 19:09

Azhar