请编程遍历页面上所有TextBox控件并给它赋值为string.Empty?

我做的时候分了2中情况:一种是窗体控件,另一种是web控件。

窗体控件:

View Code
foreach (System.Windows.Forms.Control aa in this.Controls)  
{
if (aa is System.Windows.Forms.TextBox)
{
System.Windows.Forms.TextBox ss
= (System.Windows.Forms.TextBox)aa;
ss.Text
= String.Empty;
}
}

Web控件:

View Code
foreach (System.Web.UI.Control aa in this.FindControl("form1").Controls)  
{
if (aa is System.Web.UI.WebControls.TextBox)
{
System.Web.UI.WebControls.TextBox ss
= (System.Web.UI.WebControls.TextBox)aa;
ss.Text
= String.Empty;
}
}

相关文章:

  • 2022-12-23
  • 2021-07-11
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2021-07-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案