Solved

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

Posted on 2013-11-05
5
489 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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…

778 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