detect IE shutdown or closing form

Discussion in 'ASP .Net' started by someone, Nov 16, 2005.

  1. someone

    someone Guest

    Hi,

    Is it possible to detect if the user has shut down the window holding my
    ASP2.0 page and/or if the user goes to another page?
    For my application I need the user to click on the EXIT button instead of
    just going to another page or discard the window completely.

    My application is in VB.NET ASP2.0.

    thanks,
    Eric
    someone, Nov 16, 2005
    #1
    1. Advertising

  2. someone

    Marina Guest

    You can handle the client side onbeforeunload event. However, that event
    will fire even if the page is just posting back to itself, so you need to
    figure in that code if the user just did something on your form forcing it
    to post back, or if it is something else.

    "someone" <> wrote in message
    news:437b7c5d$0$2345$...
    > Hi,
    >
    > Is it possible to detect if the user has shut down the window holding my
    > ASP2.0 page and/or if the user goes to another page?
    > For my application I need the user to click on the EXIT button instead of
    > just going to another page or discard the window completely.
    >
    > My application is in VB.NET ASP2.0.
    >
    > thanks,
    > Eric
    >
    >
    Marina, Nov 16, 2005
    #2
    1. Advertising

  3. As Marina suggested, your best bet is JavaScript and mapping a function to
    onbeforeunload:

    Your HTML should end something like:

    </BODY>
    <script language=JavaScript>
    function WarnBeforeExit() {
    ...
    }
    window.onbeforeunload = WarnBeforeExit();
    </script>

    One problem you may encounter is that some controls will cause a PostBack, in
    which case you don't want the warning. In those cases you'll need to set a
    variable/hidden field value so that your WarnBeforeExit() function will be
    suppressed in those cases.

    Example for your code-behind page:
    myButton.Attributes.Add("onclick", "javascript:hdnBypassWarning.
    value='true';")

    Then in your WarnBeforeExit() function:
    if (document.form.hdnBypassWarning.value != 'true')
    return 'I DO NOT WANT YOU LEAVING THIS PAGE DAMMIT';


    HTH,
    Darren



    someone wrote:
    >Hi,
    >
    >Is it possible to detect if the user has shut down the window holding my
    >ASP2.0 page and/or if the user goes to another page?
    >For my application I need the user to click on the EXIT button instead of
    >just going to another page or discard the window completely.
    >
    >My application is in VB.NET ASP2.0.
    >
    >thanks,
    >Eric


    --
    Message posted via DotNetMonster.com
    http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/200511/1
    Darren Mart via DotNetMonster.com, Nov 16, 2005
    #3
  4. someone

    someone Guest

    Thanks, Marina!

    "Marina" <> schreef in bericht
    news:...
    > You can handle the client side onbeforeunload event. However, that event
    > will fire even if the page is just posting back to itself, so you need to
    > figure in that code if the user just did something on your form forcing it
    > to post back, or if it is something else.
    >
    > "someone" <> wrote in message
    > news:437b7c5d$0$2345$...
    >> Hi,
    >>
    >> Is it possible to detect if the user has shut down the window holding my
    >> ASP2.0 page and/or if the user goes to another page?
    >> For my application I need the user to click on the EXIT button instead of
    >> just going to another page or discard the window completely.
    >>
    >> My application is in VB.NET ASP2.0.
    >>
    >> thanks,
    >> Eric
    >>
    >>

    >
    >
    someone, Nov 16, 2005
    #4
    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. Austin

    How to detect windows shutdown

    Austin, Apr 6, 2005, in forum: Python
    Replies:
    4
    Views:
    551
    vincent wehren
    Apr 7, 2005
  2. Austin

    Detect windows shutdown

    Austin, Jun 22, 2005, in forum: Python
    Replies:
    2
    Views:
    642
    Chris Lambacher
    Jun 23, 2005
  3. =?Utf-8?B?Vk1J?=

    Closing popup window when closing parent window?

    =?Utf-8?B?Vk1J?=, Feb 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    644
    Thomas Hansen
    Feb 15, 2007
  4. red floyd
    Replies:
    0
    Views:
    457
    red floyd
    Dec 23, 2008
  5. thomas
    Replies:
    0
    Views:
    218
    thomas
    Oct 23, 2003
Loading...

Share This Page