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.
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>
drenuka
Member
3 Points
29 Posts
Login Close Event
Mar 19, 2009 10:42 AM|LINK
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.
vinz
All-Star
116098 Points
16314 Posts
MVP
Re: Login Close Event
Mar 20, 2009 06:21 AM|LINK
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..
MessageBox Controls for WebForms |Blog
mudassarkhan
All-Star
77546 Points
13188 Posts
MVP
Re: Login Close Event
Mar 20, 2009 06:39 AM|LINK
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
Contact me