c# - Check All Checkboxs feature Asp.net -
i want ask question(how implement "select all" check box in html?) asp.net point of view. there seems more challenges on come when using asp.net this. cssclass attribute generates span container class specified , doesn't placed on input. along challenge of masterpages , controls. looping through records , displaying them checkbox. hoping grab checkboxes class perform check all. don't think possible. advice?
markup:
<asp:checkbox runat="server" id="checkall" cssclass="checkall" /> <asp:table id="tblitems" visible="false" width="80%" horizontalalign="center" runat="server"> <asp:tablerow> //the data gets added table row. </asp:tablerow> </asp:table>` browser:
//check check box <span class="checkall"><input id="ctl00_contentplaceholder1_checkall" type="checkbox" name="ctl00$contentplaceholder1$checkall" /></span> //each checkbox checked looks <span class="chkbox"><input id="ctl00_contentplaceholder1_ctl01" type="checkbox" name="ctl00$contentplaceholder1$ctl01" /></span> javascript
$('.checkall').click(function (event) { alert("start"); if (this.checked) { // iterate each checkbox $(':checkbox').each(function () { this.checked = true; }); alert("end"); } });
clientidmode property of checkbox control allow more work client-side selectors, this:
markup:
<asp:checkbox runat="server" id="checkall" cssclass="checkall" clientidmode="static" /> check out control.clientidmode property msdn documentation.
note: clientidmode available in asp.net 4.0 , later.
Comments
Post a Comment