ASP.NET - reset button - Asked By Ashok Kumar on 10-Apr-10 08:54 AM

hii every one..
i hav many fields in my web page such as(name,id,designation etc..)
i hav a add button and if i click the add button it add my textbox values to my page..
i do hav another button(clear),if i click the clear button it should reset all my textbox values...
so i need a sample idea/code regarding that concept
anyone plz  help me out........
Ashok!
good day......
Goniey N (Mr. G) replied to Ashok Kumar on 10-Apr-10 09:05 AM
//On Your Clear Button Click Event Write Just :

id.Text=""
name.Text=""

//Like This Use All Textbox To Null..

//I Hope This Will Helpful To You...
Super Man replied to Ashok Kumar on 10-Apr-10 10:06 AM

you can use

 <input type=reset  />

in your .aspx page

Carey H replied to Super Man on 10-Apr-10 12:49 PM
Or what's even the easiest solution...

response.redirect("~/yourpage.aspx")

If you are simply clearing everything and starting over then the above makes sure everything is reset.

You can also do this in javascript so as not to make a trip back to the server which so far all the examples require.

Assuming it is not nested in another control:

document.getElementById(

'<%=tbTest.ClientID%>').value = ""

Assuming your textbox is in a formview:

document.getElementById(

'<%= formview1.findcontrol("your_textbox").ClientID %>').value = ""