Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
New to SOAP and need some direction 10 40
Runtime Exceptions when trying to submit data 28 36
Error in query expression 3 31
Web Form VB.Net  import CSV 4 17
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

943 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now