Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Reset a Web Page to initial state via Button

Posted on 2003-12-03
8
Medium Priority
?
932 Views
Last Modified: 2012-08-13
Have a web page with 30+ controls of most types(textboxes, dropdown lists, checkboxes...)

User presses a SAVE button (System.Web.UI.WebControls.Button)

From the .net codebehind want to perform various tasks (already written) and then reload / reinitialize the page as if just loaded for the first time.  The actual URL does have some values set ie.  page.aspx?id=1&name=test

Programming in VB.net

Would think this would be easy but have found no simple solution yet...
0
Comment
Question by:dante469
  • 4
  • 2
  • 2
8 Comments
 
LVL 12

Expert Comment

by:roverm
ID: 9869720
Set the viewstate(s) to 'False'. That should do the trick.

D'Mzz!
RoverM
0
 
LVL 7

Author Comment

by:dante469
ID: 9869752
Looking for a modular solution that will work on any web form w/o having to hardcode each control...

Goal is the user hits the SAVE button (record is saved) then form is cleared and user can fill out again and press the SAVE button again...  This process should be repeatable over and over...
0
 
LVL 12

Expert Comment

by:roverm
ID: 9869790
Hmm, how about adding some javascript to reset all values:

<script language="javascript">
  function window.onload()
    { document.forms(0).reset(); }
</script>

D'Mzz!
RoverM
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 7

Author Comment

by:dante469
ID: 9870317
Dim sc As String = "<script language='javascript'> function window.onload() { document.forms(0).reset(); } </script>"

RegisterStartupScript("a", sc)

Does not work :(....
0
 
LVL 18

Accepted Solution

by:
testn earned 750 total points
ID: 9871878
Just do this....

Response.Redirect("page.aspx?id=1&name=test")

:) It should work
0
 
LVL 7

Author Comment

by:dante469
ID: 9874254
testn- Like the approach, however looking for a generic solution and the arguments passed on the command line can/will change.  Soo close :)...
0
 
LVL 7

Author Comment

by:dante469
ID: 9874413
testn- The following code is a generic solution based on your approach:

Response.Redirect(Request.Url.AbsoluteUri, False)

Awarding you the points...  Thank you :)...
0
 
LVL 18

Expert Comment

by:testn
ID: 9879678
Thanks :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Screencast - Getting to Know the Pipeline
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question