哦,你可以看看运行结果源文件,就是运行页面,然后 查看=>源文件,里面的什么checkboxlist好像都是用表格来控制格式的,然后根据客户端的dom来循环访问设置其状态

解决方案 »

  1.   

    CheckBox1在客户端根据ID就可以更改值Document.Form.CheckBox1.value=true;就可以了
      

  2.   

    <HTML>
    <HEAD>
    <title id="mytitle">WebForm1</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    <script language="javascript">
    function checkall(obj)
    {
      var icount=0;
      for(icount=0;icount<document.all.length;icount++)
      {
        if(document.all[icount].id.substring(0,13)=="CheckBoxList1")
        {
          if(obj.checked==true)
          {
            document.all[icount].checked=true;
          }
          else
          {
            document.all[icount].checked=false;
          }       
        }
      }
    }
    </script>
    </HEAD>
    <body MS_POSITIONING="FlowLayout">
    <form id="Form1" method="post" runat="server">
    <FONT face="宋体"><INPUT style="WIDTH: 48px; HEIGHT: 20px" type="checkbox" id="mychk" onclick="checkall(this)">
    <asp:CheckBoxList id="CheckBoxList1" runat="server">
    <asp:ListItem Value="item1">item1</asp:ListItem>
    <asp:ListItem Value="item2">item2</asp:ListItem>
    <asp:ListItem Value="item3">item3</asp:ListItem>
    </asp:CheckBoxList></FONT></form>
    </body>
    </HTML>
    ------------------------------------------------------------------------------
    注意:if(document.all[icount].id.substring(0,13)=="CheckBoxList1")
    是因为CheckBoxList的id是CheckBoxList1,如下:
    <asp:CheckBoxList id="CheckBoxList1" runat="server">
      

  3.   

    以下代碼未經實測
    //代入兩個參數,要控制的控件名和控件的數量
    this.CheckBox1.Attributes["onclick"]="jscript:on_click("+CheckBoxList1.clientid+","+CheckBoxList1.items.count.tostring()+");";js代碼類似以下
    function on_click(obj,MaxIndex){
      for(var i=0;i<MaxIndex;i++){
        (eval(obj+"_"+i)).selected=true;
      }
    }
      

  4.   

    以下代碼未經實測
    //代入兩個參數,要控制的控件名和控件的數量
    this.CheckBox1.Attributes["onclick"]="jscript:on_click("+CheckBoxList1.clientid+","+CheckBoxList1.items.count.tostring()+");";js代碼類似以下
    function on_click(obj,MaxIndex){
      for(var i=0;i<MaxIndex;i++){
        (eval(obj+"_"+i)).selected=true;
      }
    }