PageMethods Example
Lets look at a simple example of how to use PageMethods.The things you need to do in your code behind is add
- using System.Web.Script.Services;
- using System.Web.Services;
In .Cs(Code behind) file write the code
[ScriptMethod, WebMethod]
public static string callLogoff()
{
// to do your code
return "what you want"
}
In ASPX Page
Add scriptmanager this within form method and make
EnablePageMethods="true"
- Now write script method within head tag
function closesession() {
if (window.event.clientY < 0) {
PageMethods.callLogoff();
alert("Thank you for Visiting. Logging out now.....")
}
}
- In body tag add
---------------------------------------------
Hope this will help you.