当前位置: 移动技术网 > IT编程>开发语言>.net > ASP.NET(C#)中遍历所有控件

ASP.NET(C#)中遍历所有控件

2017年12月12日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:for (int i = 0; i < this.controls.count; i++) { foreach (system.web.ui.co
复制代码 代码如下:

for (int i = 0; i < this.controls.count; i++)
{
foreach (system.web.ui.control control in this.controls[i].controls)
{
if (control is textbox)
(control as textbox).text = "";
}
}
foreach (control cl in this.page.findcontrol("form1").controls)
{
if (cl.gettype().tostring() == "system.web.ui.webcontrols.textbox")
{
((textbox)cl).text = "";
}
}

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网