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
server.transfer("theformurl")
when the reset button is clicked.
Private Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
Me.Server.Transfer("contacts_edit.aspx")
End Sub
Good Luck!
Just be carefull when using Server.Transfer. Here are some articles for a reference:
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.
Since I can't fit all of the code in this post with the limitations, I've created a text file at http://www.douglas-county.com/scriptlibrary/test.txt that contains the complete code for my test edit page. Thanks for any & all help.
KWilliams
-----------------------
It's the end of the world as we know it...and I feel fine
It worked! So that I understand what needed to be done, does the function basically refresh the page when called by the OnClick event through the button?
I'm just trying to understand how and why things work the way they do with ASP.NET/VB.NET, so that I don't have to repeat this question in the future. Thanks again for all of your help!
KWilliams
-----------------------
It's the end of the world as we know it...and I feel fine
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.
Bookmarks