Here is my problem :
I want to manage the state of a checkbox in a webform page using visual studio 2010 to which i have reduced the code to the strict minimum for you to better understand my problem.
In order to get the state of my checkbox dynamically created i have tried severals things :
- At the beginning my wish was simply : get the state of my checkbox in code-behing which is for my case the c# but i quickly realised that i needed to put the attribute runat="server" to the spans that contains the state of my checkbox
- So i have changed the dynamic declaration of the spans and i have added the attributes "id" and "runat" to each of the two spans. After, these attributes were visible in the code source when the page is generated but i still couldn't manage them in the code-behind
- I finally tried to use the DOM function :
getElementByIdbut when i check with the debugger, the variable is alwaysnull
In fact i think i just need to act when the page is fully loaded but i don't know how.
I just need to know if my checkbox is on or off.
Here is the body content :
<body>
<form id="form1" runat="server">
<div class="checkbox1" id="CB1">
<input type="checkbox" value="1"/>
</div>
</form>
<script type="text/javascript">
$(function () {
$('input[type=checkbox]').switchButton({
button_width: 10,
labels_placement: "left",
height: 22,
width: 50
});
})
</script>
</body>
The jquery script is there : Jquery
The css for the particular checkbox is there : Css
Let me know how to make this work.
GetElementById? btw, don't you need a;after width: 50?;after width because these are only parameters of switchButton managed by jQuery]in the url