Solved

C# - Cancel unload of a page in ASP.NET

Posted on 2013-11-05
5
500 Views
Last Modified: 2014-02-04
How can I cancel an unload of a page?
0
Comment
Question by:CipherIS
  • 2
5 Comments
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 39626593
Refering to the page lifecycle in ASP.net, page unload is the last thing that happens... page is fully rendered, no modifications are possible mainly because everything is already sent to the client.
Page objects are still available but marked to be disposed.

So what exactly do you want to cancel?
0
 
LVL 1

Author Comment

by:CipherIS
ID: 39627734
I need to check hte value of a viewstate and depending on the viewstate value the user will be allowed to continue or must stay on that page.

I put response.redirect on the page.unload but that caused an error.
0
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 500 total points
ID: 39633030
I put response.redirect on the page.unload but that caused an error.
As I told you before, and you can check on the ASP.net request lifecycle, there's nothing you can do on page.unload...

If you try to do a page.redirect on page.unload this means you're trying to redirect after the page is already been sent to the client!

Can't you just do this on Page.Load?
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 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