title: Using JQuery - Auto Complete Text Box In ASP.Net C#
body: <p>I'm trying to autocomplete textbox with items from a database table; however it is not auto completing. No information is not pulling from the database even though there's data. What am I doing differently that the autocomplete is not working.</p>
  
  <pre><code>&lt;head runat="server"&gt;
  
   &lt;link href="jquery-ui.css" rel="stylesheet" type="text/css" /&gt;  
  &lt;script src="jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;  
  &lt;script src="jquery-ui.min.js" type="text/javascript"&gt;&lt;/script&gt;  
  
  &lt;script type="text/javascript"&gt;  
      $(document).ready(function() {  
          SearchText();  
      });  
      function SearchText() {  
          $("#txtInvoiceNum").autocomplete({  
              source: function(request, response) {  
                  $.ajax({  
                      type: "POST",  
                      contentType: "application/json; charset=utf-8",  
                      url: "LoadSheet.aspx/GetInvoice",  
                      data: "{'invoiceNum':'" + document.getElementById('txtInvoiceNum').value + "'}",  
                      dataType: "json",  
                      success: function(data) {  
                          response(data.d);  
                      },  
                      error: function(result) {  
                          alert("No Match");  
                      }  
                  });  
              }  
          });  
      }  
  &lt;/script&gt;   
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;asp:TextBox ID="txtInvoiceNum" runat="server"&gt;&lt;/asp:TextBox&gt;
  
    [WebMethod]
  public static List&lt;string&gt; GetInvoice(string invoiceNum)
  {
      List&lt;string&gt; empResult = new List&lt;string&gt;();
      using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TWCL_OPERATIONSConnectionString"].ConnectionString))
      {
          using (SqlCommand cmd = new SqlCommand())
          {
              cmd.CommandText = "select Top 10 SOPNUMBE from [TWCL].[dbo].[SOP10100] where  SOPNUMBE LIKE ''+@SearchInvoice+'%'";
              cmd.Connection = con;
              con.Open();
              cmd.Parameters.AddWithValue("@SearchInvoice", invoiceNum);
              SqlDataReader dr = cmd.ExecuteReader();
              while (dr.Read())
              {
                  empResult.Add(dr["SOPNUMBE"].ToString());
              }
              con.Close();
              return empResult;
          }
      }
  }
  </code></pre>