I have a jQuery function as below which i want to be called on a checkbox click. when I use an input type="checkbox"
it works fine. But I want to check/uncheck the checkbox from c# code(fillform()) and based on that the javascript function also has to execute
but if i set runat="server"
or if i use asp:checkbox
then the below function is not called.
I tried using the below code for asp:checkbox as well as for input box in page_load. but the function is not called
c# code
Page_load
{
chkVehicle.Attributes.Add("onclick", "toggleVehicle();");
}
FillForm
{
chkVehicle.Checked = ObjUR.HasVehicle;
}
jQuery function
function toggleVehicle() {
if ($('#chkVehicle').is(':checked')) {
$('#divVehicle :input').removeAttr('disabled');
$('#divVehicle').css({ "background-color": 'transparent' });
} else {
$('#divVehicle :input').attr('disabled', true);
$('#divVehicle').css({ "background-color": 'gray' });
}
}
please help