HighTechTalks DotNet Forums  

Is there a way to tell if a user is leaving the page?

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss Is there a way to tell if a user is leaving the page? in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Chris Roden
 
Posts: n/a

Default Is there a way to tell if a user is leaving the page? - 12-13-2007 , 11:59 AM






I am working on an ASP.NET application utilizing .NET 3.5. One page is using
a multi-view with 10 views. UpdatePanels are used to navigate from one view
to another. There are hundreds of fields and I want to be able to prompt the
user to save if they are leaving the PAGE, not the view. The user should be
able to move freely from view to view, but should be prompted to save if they
try to leave the page. I am at a loss and can't figure this out. Any
assistance is greatly appreciated!


Reply With Quote
  #2  
Old   
Mark Rae [MVP]
 
Posts: n/a

Default Re: Is there a way to tell if a user is leaving the page? - 12-13-2007 , 12:11 PM






"Chris Roden" <ChrisRoden (AT) discussions (DOT) microsoft.com> wrote


Quote:
Any assistance is greatly appreciated!
Not possible.

There are several suggested kludges with <body onunload> but none of them
works properly.

Don't even bother trying...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net



Reply With Quote
  #3  
Old   
Peter Bromberg [C# MVP]
 
Posts: n/a

Default RE: Is there a way to tell if a user is leaving the page? - 12-13-2007 , 01:00 PM



Chris,
You have to remember that whatever a user does with your "page" once it gets
into their browser, there is no way the server can have any "knowledge" of
this. There are some things you can do client-side, however. This is an old
article but all the concepts still hold:
http://www.eggheadcafe.com/articles/20010406.asp
--Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


"Chris Roden" wrote:

Quote:
I am working on an ASP.NET application utilizing .NET 3.5. One page is using
a multi-view with 10 views. UpdatePanels are used to navigate from one view
to another. There are hundreds of fields and I want to be able to prompt the
user to save if they are leaving the PAGE, not the view. The user should be
able to move freely from view to view, but should be prompted to save if they
try to leave the page. I am at a loss and can't figure this out. Any
assistance is greatly appreciated!


Reply With Quote
  #4  
Old   
msgroup
 
Posts: n/a

Default Cross-browser instant message and remote JavaScript callback - 12-13-2007 , 01:04 PM



Hi, Chris:

It seems to me that SocketPro is able to solve your particular problem. See
the site http://www.udaparts.com/document/art...ercallback.htm

function onMyUnload() //close socket connection

{

if(clientsocket){

handler.tell('I am leaving this page now ......');

clientsocket.WaitAll();

if(handler)

clientsocket.Detach(handler);

clientsocket.Disconnect();

}

clientsocket = null;

handler = null;

}



Cheers!



"Chris Roden" <ChrisRoden (AT) discussions (DOT) microsoft.com> wrote

Quote:
I am working on an ASP.NET application utilizing .NET 3.5. One page is
using
a multi-view with 10 views. UpdatePanels are used to navigate from one
view
to another. There are hundreds of fields and I want to be able to prompt
the
user to save if they are leaving the PAGE, not the view. The user should
be
able to move freely from view to view, but should be prompted to save if
they
try to leave the page. I am at a loss and can't figure this out. Any
assistance is greatly appreciated!




Reply With Quote
  #5  
Old   
Mark Rae [MVP]
 
Posts: n/a

Default Re: Is there a way to tell if a user is leaving the page? - 12-13-2007 , 02:51 PM



"Peter Bromberg [C# MVP]" <pbromberg (AT) yahoo (DOT) NoSpamMaam.com> wrote


Quote:
There are some things you can do client-side, however.
Yes, but that's just common sense validation... As you say, the server can't
know anything of this...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.