Search
Sponsor
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Forums Author
Sat, 29-Nov-2014 Authors
All Time Authors
Jayakumars
4210
Karthikanbarasan
3455
Shanky11
3150

Latest members | More ...


(Statistics delayed by 5 minutes)
 Forum Post

Browser[X] button prob.. asp.net

Susantaown
Posted by Susantaown under ASP.NET on 8/19/2009 2:00:55 AM | Views : 1326 | Status : [Member] | Replies : 1


Hi All

I Want to use one method in Browser [X] button.. but its not working here is code ..

I use this shot of code in Master.aspx page
--------------------------------------------------
<body onunload="signOut();">

<script type="text/javascript" language="javascript">
function signOut()
{
PageMethods.signOut();
}
</script>



<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />


in .cs file the method is
------------------------------
public void signOut()
{
Session["UserName"] = null;
Session["UserName"] = "";
Session.Abandon();
FormsAuthentication.SignOut();
Response.Redirect("~/Logon.aspx");
}


Can any body suggest why its not working for browser [X] button..

the same method working for my Logout Button. but if the user close the browser i want to call this method..

Need a quick help...?

susant



Posted by: Raja on: 8/19/2009 [Member] Starter

You may need to declare signOut method as WebMethod.

[WebMethod]

public void signOut()
{
Session["UserName"] = null;
Session["UserName"] = "";
Session.Abandon();
FormsAuthentication.SignOut();
Response.Redirect("~/Logon.aspx");
}


Look for this article to see how a PageMethod is called.

http://www.dotnetfunda.com/articles/article454.aspx

Thanks

Regards,
Raja, USA

Susantaown, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response


Found interesting? Add this to: