<head runat="server"> <title></title> <script type="text/javascript"> function ShowCurrentTime() { PageMethods.GetCurrentTime(document.getElementById("<%=txtUserName.ClientID%>").value, OnSuccess);}function OnSuccess(response, userContext, methodName) { alert(response);}</script></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager> <div> Your Name :<asp:TextBox ID="txtUserName" runat="server" ></asp:TextBox><input id="btnGetTime" type="button" value="Show Current Time" onclick="ShowCurrentTime()"/> </div> </form></body> protected void Page_Load(object sender, EventArgs e) { } [System.Web.Services.WebMethod] public static string GetCurrentTime(string name) { return "Hello " + name + Environment.NewLine + "The Current Time is: " + DateTime.Now.ToString(); }
now what I need is I need another method only with name that is obtained from WebMethod and on button click I need to display the name with