請編程遍歷頁面上所有TextBox控件並給它賦值爲string.Empty?(webform&winform)

webform:

 

 

Code
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:

Code
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 ;
}
}

惡寒!剛剛就看了哈首頁的要求,可能是無意點了哈那四行字 怎麼就發到首頁去了,尷尬!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章