It seems that this is a more complex case in asp.net. I am using using the validators that
are in .net (i.e. RangeValidator, CustomValidator...). Does this make it more complex?
Will the validator message reset wilt the control???
What would be the best way to reset this form. I saw a post once (can't find it now)
that said I could use Response.Redirect.
To run a server side script the page has to be sent back to the server, so you might as well just redirect the user back to the form since his page will refresh anyway. That is the kind of cheating method, but it will work. I would use
when the reset button is clicked.
If you write your program in Microsoft Visual Studio.Net, when you add a web server button control, on your code behind page you get automatically the statement:
Protected WithEvents btnReset As System.Web.UI.WebControls.Button
If you don't have this line of code, your code will not work. Add this variable at the class level of your code behind page. If it doesn't work again, please, post some of your code, so we can have a better idea of what is going on.
I'm actually using the ASP.NET Web Matrix GUI for my apps. I added that line of code before the other code to see what would happen, and received this error: BC30260: 'btnReset' is already declared as 'Protected Dim btnReset As System.Web.UI.WebControls.Button' in this class.
1. The page is posted back to the server and the Page_Load event is executed.
2. Then the btnReset_Click event is executed.
3. Since you have Server.Transfer("whatever.aspx") in btnReset_Click, the server transfers the execution to the "whatever" page you specify.
4. When the navigation is transfered to that page, it loads it like it is loaded for a first time (which means that the code inside the "If not me.isPostBack then" will be executed) and all of the controls will get their initial values.
If you can put breakpoints inside the above mentioned functions you will see what is going on.