I have something that depending if it is clicked or unclicked will do something. The thing is, that i tried to do an onclick and it will not fire. Is there some other thing that is needed for selecting/unselecting a checkbox?
ASP:
<div id = "gridDiv">
Turn on/off some code:
<asp:Checkbox runat="server" name = "gridlock" id = "gridLockAttribute" />
</div>
ClientSide:
$("#gridLockAttribute").click(function(){
try{
alert("test");
}catch(err){
}
});
It doesnt seem to alert.
ASP.NET may be name-mangling your ID if the control is within another control, so things like
$("#gridLockAttribute")won’t work. You have to use either:Or:
I’d prefer the first method.
Furthermore, if you are trying to get the checkbox to cause a postback automatically, you’ll need to set the
AutoPostBackattribute on the checkbox toTrue.