<form id="form1" runat="server">
    <div>
    <input  type="button" id="button1" runat="server" value="ok"/>
    <input  type="checkbox" id="checkbox1" runat="server" title="cb1"/>
    <input  type="checkbox" id="checkbox2" runat="server" title="cb2"/>
    <input  type="checkbox" id="checkbox3" runat="server" title="cb3"/>
    <input  type="button" id="button2" runat="server" value="cancel"/>
        <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Button" /></div>
    </form>

解决方案 »

  1.   

    foreach (Control c in this.form1.Controls)
                {
                    if (c is HtmlInputCheckBox)
                    {
                        HtmlInputCheckBox b= c as HtmlInputCheckBox;
                       
                    }
                }
      

  2.   

    foreach(Control   ctl   in   Page.FindControl("Form1").Controls)  
      {  
                if(ctl   is   HtmlInputCheckBox )  
                {  
                   if((ctl   as   HtmlInputCheckBox ).Checked)   
                     {                 }  
               }  
      }
      

  3.   

    foreach (Control c in this.form1.Controls) 
                { 
                    if (c is HtmlInputCheckBox) 
                    { 
                        HtmlInputCheckBox b= c as HtmlInputCheckBox; 
                      
                    } 
                }
      

  4.   


    //测试通过!速度慢了!
    foreach (Control control in this.form1.Controls)
            {
                if (control is HtmlInputCheckBox)
                {
                    HtmlInputCheckBox cbx = (HtmlInputCheckBox)control;
                    cbx.Checked = true;
                }
            }
      

  5.   


    function findcontrol()
    {
      var inputs = document.body.getElementByTagName("input");
      var t=0;
      for(var i=0;i<inputs.length;i++ )
      {
        if(inputs[i].type == "checkbox")
         t++;
      }
      alert("选择了"+t+"个checkbox")
    }
      

  6.   


    <form id="form1" runat="server">
        <div>
        <input  type="button" id="button1" value="ok"/>
        <input  type="checkbox" id="cb "title="cb1"/>
        <input  type="checkbox" id="cb"  title="cb2"/>
        <input  type="checkbox" id="cb"title="cb3"/>
        <input  type="button" id="button2" runat="server" value="cancel"/>
            <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Button" /> </div>
        </form>
    这样怎么找出id是cb的input