I want to make a ajax server control in ASP.NET and in that application I have a textbox and I want to send text of that textbox to function that is created in ASP.NET ajax
MyPage.aspx:
...
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/MyService.asmx" />
</Services>
</asp:ScriptManager>
...
<script>
MyNameSpace.MyService.MyMethod('some text', responseHandlerMethod, errorHandlerMethod);
</script>
...
MyService.asmx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
namespace MyNameSpace
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class MyServiceClass: System.Web.Services.WebService
{
[ScriptMethod]
[WebMethod]
public string MyMethod(string SomeText)
{
return "Hi mom! " + SomeText;
}
}
}