Call webservice in asp.net using javascript
Create a webservice (eg:WebService1.asmx) and add following codes in your webservice cs page
[WebMethod]public string GetCurrentTime(string name){return "Hello " + name + Environment.NewLine + "The Current Time is: "+ DateTime.Now.ToString();}
2) Add the following attribute to the Web Service declaration part: [System.Web.Script.Services.ScriptService]
3) Create new aspx page say webform1.aspxand add following in script page
<asp:ScriptManager ID="ScriptManager1" runat="server"><Services><asp:ServiceReference Path="~/WebService1.asmx" /></Services></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><script type = "text/javascript">function ShowCurrentTime1(){var name=document.getElementById("<%= txtUserName.ClientID %>").value;TESTAPP.WebService1.GetCurrentTime(name,resultvalue);}function resultvalue(result){alert(result);}
</script>
TAGS-cALL WEBSERVICE FROM ASP.NET -WEBSERVICE JAVASCRIPT-CALL WEBSERVICE IN ASP.NET SCRIPT PAGE