Hello All,
I've been trying to implement the AutoCompleteExtender control from the Ajax Toolkit. So far everything has been working properly. The only issue I have is that after the webservice call completes the results are not being displayed. There are no error messages being displayed so I'm at a loss as to how to fix it. Searching forums and Google hasn't turned up any ideas. Hopefully someone with more experience here can help me out.
Here's the offending code.

<asp:TextBox ID="Location_1" runat="server" CssClass="box" tabindex="1"                          autocomplete="off" />
<ajaxToolkit:AutoCompleteExtender ID="Location_1_Extender" runat="server" 
                                TargetControlID="Location_1" ServiceMethod="GetLocationList" 
                                ServicePath="~/LocationLookup.asmx" CompletionSetCount="15" 
                                CompletionInterval="1000" MinimumPrefixLength="2"
                                DelimiterCharacters="," EnableCaching="true"  />
[System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod]
    public string[] GetLocationList(string prefixText, int count)
    {
        SqlConnection GetLocationsConnection = WebToolsConnections.WebToolsConnectionStrings.GetDatabaseConnection();

        SqlCommand GetLocationsCommand = GetLocationsConnection.CreateCommand();

        prefixText = prefixText.Trim();

        string QueryString = "SELECT TOP 15 [City], [State], [Codes] FROM [CDNLA].[PostalData] WHERE ";
        QueryString += "[City] LIKE '" + prefixText + "%' OR ";
        QueryString += "[State] LIKE '" + prefixText + "%' OR ";
        QueryString += "[Codes] LIKE '" + prefixText + "%' ";
        QueryString += "ORDER BY [State], [City], [Codes]";

        GetLocationsCommand.Parameters.AddWithValue("@Value", prefixText);

        DataTable ResultsTable = new DataTable();

        try
        {
            GetLocationsConnection.Open();

            GetLocationsCommand.CommandText = QueryString;

            SqlDataAdapter GetLocationsAdapter = new SqlDataAdapter(GetLocationsCommand);

            GetLocationsAdapter.Fill(ResultsTable);
        }
        catch (Exception Ex)
        {
            ResultsTable = new DataTable();
        }
        finally
        {
            GetLocationsConnection.Close();
        }

        if (ResultsTable.Rows.Count > 0)
        {
            string[] ResultsArray = new string[ResultsTable.Rows.Count];

            for (int i = 0; i < ResultsTable.Rows.Count; i++)
            {
                ResultsArray[i] = ResultsTable.Rows[i].ItemArray[0] + ", " + ResultsTable.Rows[i].ItemArray[1] + ", " + ResultsTable.Rows[i].ItemArray[2];
            }
            
            return ResultsArray;
        }
        else
        {
            return new string[1] {"No Results Returned"};
        }

    }

I've solved the problem. As it turns out I left the EnablePageMethods=true off of the scriptmanager that runs the page.
After enabling that it looks like the problem has been solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.