foreach (Control txtobj in this.Page.Controls)
{
if (txtobj.GetType().Name == "TextBox")
{
// ((TextBox)txtobj).Text = "";//這是第壹種方法賦值,第二種在下面
TextBox tb = new TextBox();
tb = (TextBox)this.FindControl(txtobj.ID); nbsp;
tb.Text = string.Empty;
}
後臺代碼:
foreach(Control ctl in this.Controls)
{
if(ctl is TextBox){
(ctl as TextBox).Text = string.Empty;
}}
}