Capturing the leaving of a page/http_request

G

Guest

Hi there,

i need to ensure a user does something when they exit an asp.net web page. I
cant put code behind close buttons, because there are a thousand ways they
can exit this page, menu buttons, links etc. Is there any way you can capture
the exiting of a page/the moment the server receives a request to move away
from a particular url ? Page_Unload, although it sounds ideal, actually
doesnt capture the unload of a page, but the moment that load finishes! Has
anyone needed to do this, and if so, how?

I'm working in C#.

many thanks in advance.
 
K

Karl Seguin

There's no great solution. The only way is to hook into some javascript
events such as OnBeforeUnload which tend to be IE only.

<body OnBeforeUnload="Cleanup();">

<Script langauge="javascript">
function Cleanup()
{
//do stuff
}
</script>

of course, if you need to do stuff server side, you'll have to have
Cleanup() either launch a small popup which you can then do stuff in
Page_load or use AJax to make an asynch request.

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top