Link to home
Start Free TrialLog in
Avatar of heyne230
heyne230

asked on

How to clear all the controls of an aspx page(form)?

How to clear all the controls of an aspx page
My page has combo boxes , text boxes , radio buttons etc
Client side:
i tried
document.forms[0].reset();
Did not work as its supposed to only for html pages

Server side:
this.form1.Controls.Clear();
the above statement gave me an error. y?

What is the solution using client side javascripting?
AND also if we have to do this from server side?
Avatar of UnexplainedWays
UnexplainedWays

are you using any js libs (moo / jq), if so you could do a simple select from the form and get all input/select/checkbox's and then set them back to default values.

You could do it from the code behind and iterate recursively and find all the controls that are the same type and also reset.

Are you wanting to reset on a js action, or when the form posts and you want it to be cleared?
ASKER CERTIFIED SOLUTION
Avatar of thaytu888888
thaytu888888
Flag of Viet Nam image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial