Friday 7 December 2012

Execute server side code on close of a browser

Execute server side code on close of a browser

To start with create a new page and add an instance of the ScriptManager to it. Now configure the ScriptManager to enable calling of page methods marked with WebMethod attribute.

<asp:scriptmanager id="Scriptmanager1" runat="server" enablepagemethods="true" 

The next step is to create a web method on the server. 
The method needs to be marked with the WebMethod attribute.

public static void BrowserCloseMethod()
    // Write Custom Code

Finally call the server method on closing the client browser window. Add
 a javascript method and call this method when the unload event for body
 of the browser is called.

<script language="javascript" type="text/javascript">
function Browser_Close() 
<body onunload="Browser_Close()"></body> 

No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top