遍历页面中文本框(没规律)

来源:互联网 发布:故障诊断软件 编辑:程序博客网 时间:2024/05/16 06:20
foreach(Control mycontrol in Page.Controls[1].Controls)
   {
    if(mycontrol.GetType()==typeof(TextBox) ||mycontrol.GetType()==typeof(HtmlInputText))
    {
     if(mycontrol.GetType()==typeof(HtmlInputText))
     {
      //取((HtmlInputText)mycontrol).Value 
      this.Response.Write("<script>alert("+((HtmlInputText)mycontrol).Value+")</script>");
     }
     else
     {
      //取((TextBox)mycontrol).Text
      this.Response.Write("<script>alert("+((TextBox)mycontrol).Text+")</script>");
     }
    }
   }
原创粉丝点击