Click here to Skip to main content
15,886,078 members
Please Sign up or sign in to vote.
1.35/5 (5 votes)
See more:
Hi,
How to write the coding for reset or clear button in ASP.NET???

Regards
Balamurugan
Posted
Updated 14-Nov-19 15: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...

You can do like this :

C#
protected void Reset_Click(object sender, EventArgs e)
    {
        TextBox1.Text = string.Empty;
        TextBox2.Text = string.Empty;
        // so on youe all controls
    }
 
Share this answer
 
Comments
[no name] 30-Oct-12 8:56am    
Thanks Dude.. I got it right....
[no name] 30-Oct-12 9:14am    
WC
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
 
Share this answer
 
v2
Put this code on Reset button click event

Page.Response.Redirect(Page.Request.Url.RawUrl)
 
Share this answer
 
Comments
Member 12054200 3-Nov-15 2:36am    
if the page redirect its initial page
this is my simple solution :
HTML
<button type="reset" onclick="this.form.reset();return false">Reset</button>>
 
Share this answer
 
C#
textbox1.text="";
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900