Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

AJAX AutoCompleteExtender problem returning wrong content

$
0
0

Hello and thanks for reading this problem.

I tried to follow this example But for some reason its returning the content in this picture.

<td colspan="2"><p>Pickup location</p><asp:TextBox runat="server" ID="txtLocation" /><ajax:AutoCompleteExtender ServiceMethod="SearchCustomers"
                                MinimumPrefixLength="2"
                                CompletionInterval="100" EnableCaching="false" CompletionSetCount="10"
                                TargetControlID="txtLocation"
                                ID="AutoCompleteExtender1" runat="server" FirstRowSelected="false"></ajax:AutoCompleteExtender><asp:HiddenField ID="hfCustomerId" runat="server" /></td>

C#

[System.Web.Script.Services.ScriptMethod()]
        [System.Web.Services.WebMethod]
        public static List<string> SearchCustomers(string prefixText, int count)
        {
            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = ConfigurationManager
                        .ConnectionStrings["ConnString"].ConnectionString;
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "select Name from Locations where " +"Name like @SearchText + '%'";
                    cmd.Parameters.AddWithValue("@SearchText", prefixText);
                    cmd.Connection = conn;
                    conn.Open();
                    List<string> customers = new List<string>();
                    using (SqlDataReader sdr = cmd.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            customers.Add(sdr["Name"].ToString());
                        }
                    }
                    conn.Close();
                    return customers;
                }
            }
        }

ScriptManager on my masterpage

<ajaxToolkit:ToolkitScriptManager runat="server"><Scripts><%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%><%--Framework Scripts--%><%--<asp:ScriptReference Name="MsAjaxBundle" />--%><asp:ScriptReference Name="jquery" /><asp:ScriptReference Name="bootstrap" /><asp:ScriptReference Name="respond" /><asp:ScriptReference Name="WebForms.js" Path="~/Scripts/WebForms/WebForms.js" /><asp:ScriptReference Name="WebUIValidation.js" Path="~/Scripts/WebForms/WebUIValidation.js" /><asp:ScriptReference Name="MenuStandards.js" Path="~/Scripts/WebForms/MenuStandards.js" /><asp:ScriptReference Name="GridView.js" Path="~/Scripts/WebForms/GridView.js" /><asp:ScriptReference Name="DetailsView.js" Path="~/Scripts/WebForms/DetailsView.js" /><asp:ScriptReference Name="TreeView.js" Path="~/Scripts/WebForms/TreeView.js" /><asp:ScriptReference Name="WebParts.js" Path="~/Scripts/WebForms/WebParts.js" /><asp:ScriptReference Name="Focus.js" Path="~/Scripts/WebForms/Focus.js" /><asp:ScriptReference Name="WebFormsBundle" /><%--Site Scripts--%></Scripts></ajaxToolkit:ToolkitScriptManager>

What could be the problem


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>