清除所有字段一个asp.net的形式 [英] Clearing all fields in an asp.net form
问题描述
我有一个 asp.net
格式
。在这种格式
我想清楚我在文本框输入的所有数据
, DropDownList的
等,所以我该怎么办没有去到每个文本框和设置的值。
I have an asp.net
form
. In this form
I want to clear all the data what I entered in textbox
,dropdownlist
etc. So how can I do without going to each textbox and set the value.
像 TextBox1.Text =;
等。如何我可以清除表单的所有值
like TextBox1.Text="";
etc. How can i clear all values of a form ?
推荐答案
您可以使用一个复位按钮,在客户端:
You can use a reset button , on the client side :
<input type="reset" />
另一种方法是重定向到当前网址:
Another alternative is to redirect to the current url :
Page.Response.Redirect(Page.Request.Url.RawUrl)
此技术将用户重定向到当前页面,仿佛他刚刚到达。
然而,这仅可能的,如果你的网页是不是有些回传建(因为视图状态将被重置)。
This technique will redirect the user to the current page, as if he just arrived. However, this in only possible if your page is not built with some postback (since the viewstate will be reset).
至少,你可以走了整个控件树和清晰的价值观您所选择的控制,例如基于控件的类型。
At least, you can "walk" the entire control tree and clear values of controls of your choice, based for example on the type of the control.
这篇关于清除所有字段一个asp.net的形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!