设置checkbox的选中状态

一个父节点可以包含0至多个一级子节点

 

script>

 

 

---------

 父节点标记flag="parent"

子节点标记flag="child"


    <div>
        
<div>
            
<asp:CheckBox ID="CheckBox1" runat="server" Text="CheckBox1" flag="parent" /></div>
        
<div>
            
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            
<asp:CheckBox ID="CheckBox2" runat="server" flag="child" Text="CheckBox2" /></div>
        
<div>
            
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            
<asp:CheckBox ID="CheckBox3" runat="server" flag="child" Text="CheckBox3" /></div>
        
<div>
            
<asp:CheckBox ID="CheckBox4" runat="server" Text="CheckBox4" flag="parent" /></div>
        
<div>
            
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            
<asp:CheckBox ID="CheckBox5" runat="server" Text="CheckBox5" flag="child" /></div>
        
<div>
            
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            
<asp:CheckBox ID="CheckBox6" runat="server" Text="CheckBox6" flag="child" /></div>
        
<div>
            
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            
<asp:CheckBox ID="CheckBox7" runat="server" Text="CheckBox7" flag="child" /></div>
        
<div>
            
<asp:CheckBox ID="CheckBox8" runat="server" Text="CheckBox1" flag="parent" /></div>
        
<div>
            
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            
<asp:CheckBox ID="CheckBox9" runat="server" flag="child" Text="CheckBox2" /></div>
        
<div>
            
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            
<asp:CheckBox ID="CheckBox10" runat="server" flag="child" Text="CheckBox3" /></div>
              
<div>
            
<asp:CheckBox ID="CheckBox11" runat="server" Text="CheckBox1" flag="parent" /></div>
              
<div>
            
<asp:CheckBox ID="CheckBox12" runat="server" Text="CheckBox1" flag="parent" /></div>
              
<div>
            
<asp:CheckBox ID="CheckBox13" runat="server" Text="CheckBox1" flag="parent" /></div>
     
    
</div>
   
    
</form>

 

 

);
                CheckBox2.Attributes.Add("onclick""checkBoxChanged(event)");
                CheckBox3.Attributes.Add(
"onclick""checkBoxChanged(event)");

                CheckBox4.Attributes.Add(
"onclick""checkBoxChanged(event)");
                CheckBox5.Attributes.Add(
"onclick""checkBoxChanged(event)");
                CheckBox6.Attributes.Add(
"onclick""checkBoxChanged(event)");
                CheckBox7.Attributes.Add(
"onclick""checkBoxChanged(event)");
                CheckBox8.Attributes.Add(
"onclick""checkBoxChanged(event)");

                CheckBox9.Attributes.Add(
"onclick""checkBoxChanged(event)");
                CheckBox10.Attributes.Add(
"onclick""checkBoxChanged(event)");

                CheckBox11.Attributes.Add(
"onclick""checkBoxChanged(event)");
                CheckBox12.Attributes.Add(
"onclick""checkBoxChanged(event)");
                CheckBox13.Attributes.Add(
"onclick""checkBoxChanged(event)");

相关文章: