Click here to Skip to main content
14,389,715 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,
How to write the coding for reset or clear button in ASP.NET???

Regards
Balamurugan
Posted
Updated 14-Nov-19 16:45pm
Comments
[no name] 30-Oct-12 8:38am
   
Reset or Clear What ? Please elobrate more.
[no name] 30-Oct-12 8:39am
   
If i'm clicking Clear or Reset button all the textbox values should clear...
Rate this:
Please Sign up or sign in to vote.

Solution 1

You can do like this :

protected void Reset_Click(object sender, EventArgs e)
    {
        TextBox1.Text = string.Empty;
        TextBox2.Text = string.Empty;
        // so on youe all controls
    }
   
Comments
[no name] 30-Oct-12 8:56am
   
Thanks Dude.. I got it right....
[no name] 30-Oct-12 9:14am
   
WC
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hi,

The usage of Standard ASP.Net Button is a server side control and requires additional rendition. The HTML Reset button can be used instead to improve the performace of the web application.

Add a Reset Button controls using <input> as,

<input type="reset" value="Reset" />

Regards,
Raghu
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 4

Put this code on Reset button click event

Page.Response.Redirect(Page.Request.Url.RawUrl)
   
Comments
Member 12054200 3-Nov-15 2:36am
   
if the page redirect its initial page
Rate this:
Please Sign up or sign in to vote.

Solution 5

this is my simple solution :
<button type="reset" onclick="this.form.reset();return false">Reset</button>>
   
Rate this:
Please Sign up or sign in to vote.

Solution 6

textbox1.text="";
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100