1
Answer

accessing the web method parameter in another method

below is my code which return name that is entered in textbox in the web method and displays the name current time and date as output now what i need is i only need to pass the name to another method how can i do this
 
<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

Answers (1)