471,316 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

Capturing the leaving of a page/http_request

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.
Nov 20 '05 #1
1 1333
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
--
MY ASP.Net tutorials
http://www.openmymind.net/
"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:DE**********************************@microsof t.com...
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.

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by doug | last post: by
15 posts views Thread by Tony Gahlinger | last post: by
8 posts views Thread by Zvonko | last post: by
10 posts views Thread by Andrew | last post: by
1 post views Thread by James Pittman | last post: by
6 posts views Thread by Ed Leafe | last post: by
5 posts views Thread by sachu | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.