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

Discussion in 'ASP .Net' started by Chris Roden, Dec 13, 2007.

  1. Chris Roden

    Chris Roden Guest

    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!
     
    Chris Roden, Dec 13, 2007
    #1
    1. Advertising

  2. "Chris Roden" <> wrote in message
    news:...

    > 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
     
    Mark Rae [MVP], Dec 13, 2007
    #2
    1. Advertising

  3. 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:

    > 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!
    >
     
    Peter Bromberg [C# MVP], Dec 13, 2007
    #3
  4. Chris Roden

    msgroup Guest

    Cross-browser instant message and remote JavaScript callback

    Hi, Chris:

    It seems to me that SocketPro is able to solve your particular problem. See
    the site http://www.udaparts.com/document/articles/browsercallback.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" <> wrote in message
    news:...
    >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!
    >
     
    msgroup, Dec 13, 2007
    #4
  5. "Peter Bromberg [C# MVP]" <> wrote in message
    news:...

    > 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
     
    Mark Rae [MVP], Dec 13, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    7
    Views:
    25,964
    rohit.net100
    Feb 28, 2011
  2. daveh551

    Detecting user leaving page

    daveh551, Aug 5, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    508
    Scott M.
    Aug 6, 2008
  3. Dag Sunde
    Replies:
    3
    Views:
    102
    Joakim Braun
    Mar 23, 2005
  4. Zvonko

    Capturing event user leaving page

    Zvonko, Sep 2, 2005, in forum: Javascript
    Replies:
    8
    Views:
    226
    ExGuardianReader
    Sep 10, 2005
  5. koruyucu
    Replies:
    2
    Views:
    170
    Thiago Macedo
    Jul 30, 2008
Loading...

Share This Page