JavaScript on the page can invoke a static method in the Web page, in addition to the Web service class, by using ASP.
<%@ Page Language="C #" %><%@ Import Namespace="System.Web.Services" %><%@ Import Namespace="System.Web.Script.Services" %><!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><Scriptrunat= "Server">[WebMethod] [Scriptmethod (Usehttpget= true)] public static string Servertime () {returnDateTime.Now.ToUniversalTime (). ToString (); }</Script><Scripttype= "Text/javascript"> functionpageload () {$addHandler ($get ('Timebutton'), 'Click', GetTime); } functionGetTime () {pagemethods.servertime (onservertimecomplete); } functiononservertimecomplete (result, UserContext, methodName) {alert (result); }</Script><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Headrunat= "Server"> <title>ASP. NET AJAX Pagemethod</title></Head><Body> <formID= "Form1"runat= "Server"> <Div> <Asp:scriptmanagerID= "ScriptManager1"runat= "Server"Enablepagemethods= "true"> </Asp:scriptmanager> <Div> <inputtype= "button"value= "Show Server time"ID= "Timebutton" /> </Div> </Div> </form></Body></HTML>
ASP. NET AJAX provides Pagemethods calls