Tearing my hair out - ASP.Net AJAX AutoComplete not working

 ̄綄美尐妖づ 提交于 2019-12-06 12:13:47

You also need to include your page name as the servicePath, I think.

    <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" 
            MinimumPrefixLength="1" ServiceMethod="getResults" ServicePath="droptest.aspx" 
            TargetControlID="TextBox1">
    </cc1:AutoCompleteExtender>

Try adding ServicePath to the cc1:AutoCompleteExtender with the path to the web service.

[WebMethod, ScriptMethod]
public string[] getResults(string prefixText, int count)
{

be sure to include the ScriptMethod attribute.

Right, something I've added in from these suggestions has worked!!! Still have a problem though, it works in a standalone project but adding it back into the existing project and it's not working again. So thanks for the help so far, I have a working example, just have to figure out what is killing it inside the other project now.

Make the method static:

[WebMethod]
public static string[] getResults(string prefixText, int count)
{
        string[] test = new string[5] { "One", "Two", "Three", "Four", "Five" };
        return test;
}

Update:

A shot in the dark... try moving the ScriptManager above the textbox. Also, I would set the ServicePath to "~/" simply because you mention the URL rewrites.

If you are using IIS 5.1, try to temporarily remove .* from the application setting. This wildcard setting prevents AJAX like control to work correctly.

In my case, my project use rewrite rule to remove the extension aspx. I thing the problem is that. I comment the rewrite rule in web.config. Then clear solution. Rebuild it. Clear all history in firefox / chrome (what you use). Then Ctrl+F5 or F5. Autocomplete show correctly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!