ASP.Net AJAX Autocomplete Not Working

I've looked at this link and I've tried all the suggestions there, but my Asp.Net AJAX Autocomplete still isn't working.

I have a test project with only a label, text box an the auto-completer:

<asp:ToolkitScriptManager ID="ScriptManager" runat="server">
</asp:ToolkitScriptManager>
<asp:Label ID="FieldLabel" Text="Label:" runat="server"></asp:Label>
<asp:TextBox ID="InputField" runat="server"></asp:TextBox>
<asp:AutoCompleteExtender 
    ID="Autocompleter" 
    TargetControlID="InputField" 
    ServiceMethod="GetCompletionList" 
    ServicePath="~/TestWebService.asmx" 
    MinimumPrefixLength="1" 
    CompletionInterval="1000" 
    runat="server">
</asp:AutoCompleteExtender>

I don't have any code-behind on the aspx page. In TestWebService.asmx.cs, I have:

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetCompetionList(string prefixText, int count)
{
    string[] results = { "test", "test", "test" };
    return results;
} 

In theory, my textbox should have an autocomplete dropdown containing 3 instances of the word "test". In practice, I can type anything I want into the textbox and nothing happens. Does anyone have any idea what I'm doing wrong?

Answers


It looks as if you web service method is missing an argument. Also make sure that you have set the correct styles for your autocompletion "drop-down". In other words, compare your code to the reference.


I figured it out. I misspelled the name of the WebMethod. If you notice, its "GetCompetionList", not "GetCompletionList".

Now everything works.


you should to use

the word (static) after Public in your code

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]

public static string[] GetCompetionList(string prefixText, int count)

{
  string[] results = { "test", "test", "test" };


   return results;

} 

I was facing the similiar issue and that was resolved by deleting these lines in web.config file.

<rules>
        <rule name="san aspx">
          <!--Removes the .aspx extension for all pages.-->
          <match url="(.*)"/>
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" />     
          </conditions>
          <action type="Rewrite" url="{R:1}.aspx"/>
        </rule>
      </rules>

Need Your Help

Java 8 method references : validation of methods at compile time

java java-8

I'd like to use the new method references of Java 8 to provide more validation of some code at compile time.

How do you avoid over-populating the PATH Environment Variable in Windows?

windows path environment-variables executable

I would like to know what are the approaches that you use to manage the executables in your system. For example I have almost everything accessible through the command line, but now I come to the l...