Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with reset button - How to clear all input?

Status
Not open for further replies.

adonet

MIS
May 4, 2004
312
US
I found I spend a lot of time to deal with input reset.
What I did like:

textbox.text = ""
dropdownlist.selectedindex = -1

Is it correct way?

 
i was looking for that solution for a while... as far as i found out yes. Trying to clear all field programmatically with something like me.Controls never worked out for me within my datagrid itemTemplates.

my code wound up like yours but for 20 textboxes, 3 DDL's, and a radio button control...
whatta pain!

an option would be to do a history.back(0) to reset the page load in a Literal, or an asp:Hyperlink right back into the same page...
 
afaik you have a button that instead of submit is reset!

<input type='reset'>

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
true, that works, via click...how would you call that in code tho?
 
make a button of that kind and make it invisible (style="visibility:hidden") and use button.click to call it.

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
this is if you want to do it client side.

otherwise i think the only sollution would be to loop through all controls and depeding on the type to the necessary action (setting the index ro clearing the text)

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
This might be worth looking at thread855-893643
Marty
 
Belive it or not, more trouble is dropdown list. I use a variable to store the selecteditem.value. Sometime variable take the value, sometime does not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top