foreach(Control c in Page.Controls)
{
  if(c.GetType().ToString()=="System.Web.UI.WebControls.CheckBox")
  {
switch(((CheckBox)c).Text)
{
case "aaa":
                        DoFunction1();
case "bbb":
                        DoFunction2();
}
  }
}

解决方案 »

  1.   

    foreach(Control ctl in this.Controls )
    {
    if(ctl.GetType().ToString() == "System.Windows.Forms.CheckBox")
    {
    MessageBox.Show(ctl.Name.ToString());
    }
    }
      

  2.   

    foreach(control ctrl in Form1.Controls)
    {
       
       if(ctrl is CheckBox)
       {
             CheckBox cb=ctrl as CheckBox;
    switch(cb.Text)
    {
    case "aaa":
                            DoFunction1();
    case "bbb":
                            DoFunction2();
    }
       }
    }