title: Jquery-UI autocomplete asp.net search text box
body: <p>I have a textbox on my front end, which I am trying to implement an auto suggestion based on what a sql query brings back. I am using the jquery libraries and imported them into my solution. When I go ahead and run this, it hits the "no match error" although I type in a letter in the search box. Am I missing something in my code? </p>
  
  <p>aspx code below:</p>
  
  <pre><code>&lt;link href="jquery-ui.css" rel="stylesheet" type="text/css" /&gt;  
  &lt;script src="Scripts/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;  
  &lt;script src="Scripts/jquery-ui.min.js" type="text/javascript"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          SearchText();
      });
      function SearchText() {
          $("#SearchBox").autocomplete({
              source: function (request, response) {
                  $.ajax({
                      type: "POST",
                      contentType: "application/json; charset=utf-8",
                      url: "CompanyPage.aspx/GetCompanyName",
                      data: "{'cmpName':'" + document.getElementById('SearchBox').value + "'}",
                      dataType: "json",
                      success: function (data) {
                          response(data.d);
                      },
                      error: function (result) {
                          alert("No Match");
                      }
                  });
              }
          });
      }
  &lt;/script&gt;  
  
  &lt;asp:TextBox ID="SearchBox" placeholder="Enter company name to search on" runat="server" Width="322px" Height="16px" style="margin-left: 22px; margin-top: 0px" OnTextChanged="SearchBox_TextChanged"&gt;&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p>aspx.cs code:</p>
  
  <pre><code> [WebMethod] 
          public static List&lt;string&gt; GetCompanyName(string cmpName)
          {
              List&lt;string&gt; cmpResult = new List&lt;string&gt;();
              string connectionString = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
              SqlConnection cn = new SqlConnection(connectionString);
              using (SqlCommand cmd = new SqlCommand("[searchCompanyName]", cn))
              {
                      cmd.Connection = cn;
                      cn.Open();
                      cmd.Parameters.AddWithValue("@CompanyName", cmpName);
                      SqlDataReader dr = cmd.ExecuteReader();
                      while (dr.Read())
                      {
                          cmpResult.Add(dr["CompanyName"].ToString());
                      }
                      cn.Close();
                      return cmpResult;
              }
  
          }  
  </code></pre>
  
  <p>SQL stored proc:</p>
  
  <pre><code>    ALTER PROCEDURE [dbo].[searchCompanyName] 
      @CompanyName varchar(50)
  AS
  BEGIN
      SET NOCOUNT ON;
  
      SELECT CompanyName FROM Company
      WHERE CompanyName like @CompanyName + '%'
  
  END
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/uwt01.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uwt01.png" alt="enter image description here"></a></p>