请问asp.net中怎么样清空页面上的所有文本框里面的值?求高手帮忙解答一下!

如题所述

可以使用循环搜索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; } } }直接把代码贴到后台就可以了。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-09-13
如果是form表单中,可以直接使用<input type="reset" value="清除" /> 恢复到加载状态

<form>
<input type="text" value="11111"/>
<input type="text" />
<input type="text" />
<input type="text" />
<input type="reset" value="清除" />
</form>本回答被网友采纳
相似回答