可以使用循环搜索Controls,清除其中文本框就行了。
protected void Button1_Click(object sender, EventArgs e) { ResetTextBox(this.Controls); } public void ResetTextBox(ControlCollection cc) { foreach(Control ctr in cc) { if(ctr.HasControls()) { ResetTextBox(ctr.Controls); } if(ctr is TextBox) { ((TextBox)ctr).Text = string.Empty; } } }直接把代码贴到后台就可以了。
温馨提示:答案为网友推荐,仅供参考