How to implement the Web Control text box reset function

Source: Internet
Author: User

After you have developed the program in ASP, the TextBox control needs reset after the data is inserted. If there are only one or two file boxes there may be no problem, if there are many text boxes on the page, you will have a problem.
In addition to a situation, some text boxes have default values and cannot be implemented as loops.

As today on the forum to see a netizen's wording:

protected void Button2_Click (object  sender, EventArgs e)    {         this ' this ' This This is this";    }


Considering that you might as well reset the other Web control checkbox,dropdownlist, so you can write an interface:



The above user reset, is all TextBox control, so you can write a class, it inherits the TextBox, and then you can implement the Reset method of the interface:


Prepare examples and demos, such as many text boxes below the page, some with default values, some not. Users first enter some values, or change the default values, then click the reset button:

<formID= "Form1"runat= "Server">    <Div>        <Asp:textboxID= "TextBox1"runat= "Server"Text= "Leo"></Asp:textbox><BR/>        <Asp:textboxID= "TextBox2"runat= "Server"></Asp:textbox><BR/>        <Asp:textboxID= "TextBox3"runat= "Server"></Asp:textbox><BR/>        <Asp:textboxID= "TextBox4"runat= "Server"Text= "Yang"></Asp:textbox><BR/>        <Asp:textboxID= "TextBox5"runat= "Server"></Asp:textbox><BR/>        <Asp:textboxID= "TextBox6"runat= "Server"></Asp:textbox><BR/>        <Asp:textboxID= "TEXTBOX7"runat= "Server"Text= "Insus.net"></Asp:textbox><BR/>        <Asp:textboxID= "TextBox8"runat= "Server"></Asp:textbox><BR/>        <Asp:buttonID= "Button1"runat= "Server"Text= "Reset"OnClick= "Button1_Click"/>    </Div>    </form>
View Code





The following is the button1_click event for the Reset Ammonium button:


Dynamic real-time operation:



Have time to implement Dropdownlist,checkbox and other controls ...

How to implement the Web Control text box reset function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.