ASP.NET(C#)中遍历所有控件
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:for(inti=0;i
复制代码 代码如下:
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 = "";
}
}