本帖最后由 zzw226 于 2012-03-13 16:00:54 编辑

解决方案 »

  1.   

    private void get_Controls(Control control)
    {
       System.Text.StringBuilder sb = new System.Text.StringBuilder();
       
       foreach(Control ctl in control.Controls)
       {
          sb.Append(ctl.ID + " ");
          get_Controls(ctl);
        }
       Response.Write(sb.ToSting());
    }protected void Page_Load(object sender, EventArgs e)
    {
        get_Controls(this);
    }
      

  2.   

    参考:获取页面中所有的CheckBox控件的ID
    protected void Page_Load(object sender, EventArgs e)
        {
            GetCheckBoxID(this.Page);
        }
        protected void GetCheckBoxID(Control control)
        {
            foreach (Control ctl in control.Controls)
            {
                if (ctl is CheckBox)
                    Response.Write(ctl.ID + "<br/>");
                if (ctl.HasControls())
                    GetCheckBoxID(ctl);
            }
        }