This chapter is relatively simple, directly on the page code:
Copy Code code as follows:
<%@ Page language= "C #" autoeventwireup= "true" codefile= "Recipe6.aspx.cs" inherits= "Recipe6"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>Recipe6</title>
<script src= "Scripts/jquery-1.4.1-vsdoc.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
$ (function () {
$ ("#<%=chkselectall.clientid%>"). Click (function () {
Simple, one line of code is done
$ ("#<%=chklist.clientid%> Input[type=checkbox]"). attr ("Checked", $ ("#<%=chkselectall.clientid%>"). is (": Checked"));
});
});
</script>
<body>
<form id= "Form1" runat= "Server" >
<div align= "Left" >
<p>
Implement full or total cancellation </p>
<fieldset style= "width:400px; height:150px; " >
<asp:checkbox id= "Chkselectall" runat= "Server" text= "Select All"/>
<asp:checkboxlist id= "chklist" runat= "Server" >
<asp:listitem value= "1" text= "C #" ></asp:ListItem>
<asp:listitem value= "2" text= "Java" ></asp:ListItem>
<asp:listitem value= "3" text= "C + +" ></asp:ListItem>
<asp:listitem value= "4" text= "JavaScript" ></asp:ListItem>
</asp:CheckBoxList>
</fieldset>
</div>
</form>
</body>
Effect Chart: