Click here to Skip to main content
15,897,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends,

I want to enable and disable a usercontrol when checkbox changed in aspx page without pageloading.

Could you please help me??

Here is my code.

function chkedchange()
{
if (document.getElementById('chkbox').checked === false) {
$("#usercontrolId").val("0");
$('#usercontrolId').attr("disabled", "disabled");
}
else {
$("#usercontrolId").removeAttr("disabled");
}
}

Thanks,
Ramana
Posted

1 solution

I like this method, since it divides the logic into event handlers based on state.
JavaScript
$('#usercontrolId :not(:checked)').click(function(){
    $("#usercontrolId").val("0");
    $('#usercontrolId').attr("disabled", "disabled");
});
$('#usercontrolId :checked').click(function(){
    $("#usercontrolId").removeAttr("disabled");
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900