I have a problem with the following code in an ASPX page:
I know the question is far closed now, but I just have faced the same problem and I want to add the solution I found, may come in handy for similar problems on the future.
When you add ASP code like:
the problem is that is not an html control, it's just something ASP made up from the twisted mind of some psycho invented, so the browser will receive something else.
The browser will receive something like:
One of many possible solutions:
The browser receive a span which content an input "checkbox" and a label for it with your text. Therefore my solution for this would be something like:
$('.test > :checkbox').click(function() {
if ($(this).attr("checked")) {
alert("checked!!!");
} else {
alert("non checked!!!");
}
});
What happened up there? This selector $('.test > :checkbox') means: find the elements with the class "test" and bring any checkbox that it contains.