The content of this chapter is relatively simple, and the page code is displayed directly:
Copy codeThe Code is 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">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<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 (){
// Very simple, just get a line of code
$ ("# <% = ChkList. clientID %> input [type = checkbox] "). attr ("checked", $ ("# <% = chkSelectAll. clientID %> "). is (": checked "));
});
});
</Script>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div align = "left">
<P>
Select All or cancel all operations </p>
<Fieldset style = "width: 400px; height: 150px;">
<Asp: CheckBox ID = "chkSelectAll" runat = "server" Text = "select all"/>
<Hr/>
<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>
</Html>
: