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

webform:

 

 


foreach (Control control in this.Form.Controls)

{

if (control is System.Web.UI.WebControls.TextBox)

{

TextBox txt
= (TextBox)control;

txt.Text
= "fdsafds";// string.Empty;

}

}

 

 

winform:


foreach (System.Windows.Forms.Control control in this.Controls)
{
if (control is System.Windows.Forms.TextBox)
{
System.Windows.Forms.TextBox tb
= (System.Windows.Forms.TextBox)control ;
tb.Text
= String.Empty ;
}
}
posted @ 2008-11-27 20:05  杨子宜  阅读(253)  评论(0编辑  收藏  举报