How to Implement the Web control text box Reset function, web control text box reset
A program has been developed in ASP. NET. After data is inserted, the TextBox control needs to be Reset. If there are only one or two file boxes, there may be no problem. If there are many text boxes on the webpage, you will have a problem.
In addition, some text boxes have default values, which cannot be implemented through loops.
For example, I saw a netizen writing on the forum today:
protected void Button2_Click(object sender, EventArgs e) { this.TextBox1.Text = this.TextBox3.Text = this.TextBox4.Text = this.TextBox5.Text = this.TextBox7.Text = this.TextBox8.Text = this.TextBox9.Text = this.TextBox10.Text = ""; }
Considering that you may Reset other Web controls such as CheckBox and DropDownList, you can write an interface:
The preceding Reset is a TextBox Control, so you can write a class that inherits TextBox and then implement the Reset method of the interface:
For example, there are many text boxes under the webpage, some of which have default values and some do not. The user first enters some values, or changes the default value, then click the Reset button:
<Form id = "form1" runat = "server"> <div> <asp: TextBox ID = "TextBox1" runat = "server" Text = "Leo"> </asp: textBox> <br/> <asp: TextBox ID = "TextBox2" runat = "server"> </asp: TextBox> <br/> <asp: textBox ID = "TextBox3" runat = "server"> </asp: TextBox> <br/> <asp: textBox ID = "TextBox4" runat = "server" Text = "Yang"> </asp: TextBox> <br/> <asp: textBox ID = "TextBox5" runat = "server"> </asp: TextBox> <br/> <asp: textBox ID = "TextBox6" runat = "server"> </asp: TextBox> <br/> <asp: textBox ID = "TextBox7" runat = "server" Text = "Insus. NET "> </asp: TextBox> <br/> <asp: TextBox ID =" TextBox8 "runat =" server "> </asp: textBox> <br/> <asp: Button ID = "Button1" runat = "server" Text = "Reset" OnClick = "button#click"/> </div> </form>View Code
The following is the Button1_Click event of the Reset button:
Dynamic Real-time operations:
Controls such as DropDownList and CheckBox can be implemented after time ......