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:
$("#<%= gridLockAttribute.ClientID %>")
Or:
$('[id$=gridLockAttribute]')
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 AutoPostBack
attribute on the checkbox to True
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.