1. 首页
  2. 数据库
  3. 其它
  4. asp.net下遍历页面中所有的指定控件的代码

asp.net下遍历页面中所有的指定控件的代码

上传者: 2021-01-03 16:56:11上传 PDF文件 26.22KB 热度 4次
1.遍历页面中所有的TextBox,并将值设置成String.Empty 代码如下: for (int j = 0; j < this.Controls.Count; j++) { foreach (object o in Page.Controls[j].Controls) { if (o is TextBox) { TextBox txt = (System.Web.UI.WebControls.TextBox)o; txt.Text = String.Empty; } } } 2.递归遍历 代码如下: private void FindAllTextBoxByPageCont
下载地址
用户评论