Solved

Reset a Web Page to initial state via Button

Posted on 2003-12-03
8
924 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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 250 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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