aspx page code:
<ajax:ScriptManager ID="ScriptManager1" runat="server">
<Services >
<ajax:ServiceReference Path="MyService.asmx" />
</Services>
</ajax:ScriptManager>
<asp:TextBox ID="txtMaterialNo"
Width="100%" runat="server" ></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" CompletionInterval="20"
MinimumPrefixLength="1" ServiceMethod="GetMaterialId"
ServicePath="MyService.asmx" TargetControlID="txtMaterialNo"> </cc1:AutoCompleteExtender>
MyService.asmx
[ScriptService]
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class MyService : System.Web.Services.WebService
public MyService()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[System.Web.Services.WebMethod]
public string[] GetMaterialId(string prefixMaterial)
{
...... code
.... return
}
}
But when I am typing into the textbox no suggestion are coming, when I am placing the breakpoint at GetMaterialId I can see that it is not coming to this function but it is calling MyService on textchange.
How to fix this? Why it is calling the constructor but not the webmethod?
You need to add the ScriptMethodAttribute like so:
[WebMethod]
[ScriptMethod]
public string[] GetMaterialId(string prefixMaterial)
{
...... code
.... return
}