Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
problem in firing event when browser is closed
yadagiri uppari
Aug 13 2013 5:35 AM
1.1k
Reply
hi...when browser is closing ,server side is not calling..pls check my code...do edit sir,if required
aspx:
<%@ Page Language='C#' AutoEventWireup='true' CodeFile='Default.aspx.cs' Inherits='_Default' %>
<!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>Detect Browser Exit</title>
</head>
<body onunload="HandleClose()">
<script type="text/javascript" language="Javascript">
function HandleClose() {
alert("Killing the session on the server!!");
PageMethods.AbandonSession();
}
</script>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server" />
</form>
</body>
</html>
codebehind:
[WebMethod]
public static void AbandonSession()
{
HttpContext.Current.Session.Abandon();
string strh = "sp_IsHistory";
SqlParameter param5 = new SqlParameter("@senderid", 1);
SqlParameter param6 = new SqlParameter("@receiverid", 5);
SqlHelper.ExecuteNonQuery(CommonSetting.GetConnectionString(true), CommandType.StoredProcedure, strh, param5, param6);
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
How to set login authentication?
How to get no of users in online?