I want to use AutoCompleteExtender for autocomplete in TextBox. But not getting the results. I have used the following syntax :
In aspx page ::
<asp:scriptmanager EnablePageMethods="true" runat="server"></asp:scriptmanager>
<asp:TextBox ID="txtautocomplete" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1"
Enabled="true" EnableCaching="true" MinimumPrefixLength="1"
ServiceMethod="GetNames" ServicePath="~/Autocomplete.asmx"
TargetControlID="txtautocomplete" runat="server">
</cc1:AutoCompleteExtender>
and in Autocomplete.asmx ::
[WebMethod]
[ScriptMethod()]
public static string[] GetNames(string prefixText, int count)
{
ArrayList sampleList = new ArrayList();
sampleList.Add("ABC"); sampleList.Add("Hello");
sampleList.Add("Hi"); sampleList.Add("Apple");
sampleList.Add("Hey");
ArrayList filteredList = new ArrayList();
foreach (string s in sampleList)
{
if (s.ToLower().StartsWith(prefixText.ToLower()))
filteredList.Add(s);
}
return (string[])filteredList.ToArray(typeof(string));
}
When I am running the Autocomplete.asmx directly then on clicking Invoke button I am getting the right results. How can I fix it?
have you tried configuring the endpoint in your web.config like this:
see http://msdn.microsoft.com/en-us/library/bb628467.aspx