Login Close Event

Last post 03-20-2009 2:39 AM by mudassarkhan. 2 replies.

Sort Posts:

  • Login Close Event

    03-19-2009, 6:42 AM
    • Member
      3 point Member
    • drenuka
    • Member since 11-25-2008, 3:56 AM
    • Posts 29

    I am using asp.net 2.0 with c#.

    i have provided login facility to user.

    Every page has logout button which stores time of logout etc.But in case user is logged in and closes the browser directly without using logout functionality.Then i want how to handle such situations.

     

    Thks.

  • Re: Login Close Event

    03-20-2009, 2:21 AM
    Answer
    • All-Star
      94,406 point All-Star
    • vinz
    • Member since 10-05-2007, 3:47 PM
    • Cebu, PH
    • Posts 13,998
    • TrustedFriends-MVPs

    You can use the  onunload  or the onbeforeunload events to execute codes when the browser is about to closed.

    You may also use Page Methods, see below

    http://aspalliance.com/1294_CodeSnip_Handle_Browser_Close_Event_on_the_ServerSide.all

    The code below will simulates the closed button of the browser when the user invoked the button and display an alert message..

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
    function doSomething()
    {
    alert('Widnow is about to close');
    }
    </script>

    </head>
    <body onunload="doSomething();">
    <form id="form1" runat="server">

    </form>
    </body>

     



    "Code,Beer and Music ~ my way of being a programmer"



  • Re: Login Close Event

    03-20-2009, 2:39 AM
    Answer
    • All-Star
      60,913 point All-Star
    • mudassarkhan
    • Member since 02-28-2008, 5:28 AM
    • Mumbai, India
    • Posts 10,698

    You can ask the user that you are about to close browser

    Refer here

    http://www.codingtips.org/javascript/confirm-closing-of-browser-window-using-onbeforeunload.html

    MAK [MVP ASP/ASP.Net]

    ASP.Net Freelancer/Consultant My Site : ASPSnippets

    Calling ServerSide methods using JavaScript

    GridView: Excel like AutoFilter Feature
Page 1 of 1 (3 items)