Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

746 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

13 Experts available now in Live!

Get 1:1 Help Now