Dim obj As Object
        For Each obj In Page.Controls(1).Controls
            If TypeOf (obj) Is TextBox Then
                Response.Write(obj.id)
            End If
        Next

解决方案 »

  1.   

    我用VB.NET写的,你自己改一改
      

  2.   

    定义一个函数
    void findcontrol(Control topctrl)
    {
      string type="";
      foreach(Control ctrl in topctrl.Controls)
        if(ctrl.HasControls())
       {
              findcontrol(ctrl) ;
          }
       type=ctrl.GetType().ToString();
        switch (type)
    { case "System.Web.UI.WebControls.TextBox" : ((TextBox)ctr).Text="it is a text box";
                break;
    case "System.Web.UI.WebControls.DropDownList" :
                  .....
                     break;
            }
    }
      

  3.   

    刚才试成功了:foreach(Object obj in Page.Controls[1].Controls)
    {
    if(obj.GetType().ToString()=="System.Web.UI.WebControls.TextBox")
    {
    Response.Write(((TextBox)obj).ID.ToString()) ;
    }
    }