Users Pricing

forum

Home Forums ASP.NET Jquery Autocomplete – MindStick

ASP.NET Jquery Autocomplete

Jayden Bell 2077 25 Aug 2014

I have an ASP.NET webforms application and trying to implement jQuery autocomplate on a text box. The server code is getting called, but nothing is displayed. I've replaced the call to the web service and added some static text and that gets displayed OK. Can anyone see what the issue is?

The server side code is here:

[WebMethod]
    public string[] ReturnPostcodes(string term)
    {
        PostcodeService postcodes = new PostcodeService();
        var results = postcodes.ReturnPostcodes().Where(p => p.Postcode.StartsWith(term.ToUpper())).Select(p => p.Postcode).Take(20).ToArray();
        return results;
    }
The HTML is here:
<tr>
        <td>Mobile Telephone:</td>
        <td><asp:TextBox runat="server" ID="txtPostcode"></asp:TextBox></td>
    </tr>
The jquery is here:
$(document).ready(function () {
        $('#ctl00_ctl00_mainContent_mainContent_txtPostcode').each(function () {
            $(this).autocomplete({
                 source: '/Postcodes.asmx/ReturnPostcodes'
            });
        });
    });


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md