ASP.NET(C#)中遍历所有控件
程序员文章站
2024-03-08 22:53:28
复制代码 代码如下: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 = "";
}
}
上一篇: Java静态方法和实例方法区别详解
推荐阅读