title: JQuery AutoComplete textbox Returning Error
body: <p>I have trried to do autocomplete text box using jquery with the below mentioned code, but I can't achieve it,I am getting error in jquery. Thanks in Advance.</p>
  
  <p>AutoCompleteTextBox.aspx :</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AutoCompleteTextBox.aspx.cs" Inherits="Ajax_Using_Jquery.AutoCompleteTextBox" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;Ajax Auto Complete Using Jquery&lt;/title&gt;
  
        &lt;link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"&gt;&lt;/script&gt;  
      &lt;script type="text/javascript"&gt;
       var UserNameInput;
  
       $(document).ready(function () {
  
              $("#&lt;%=txtName.ClientID %&gt;").autocomplete({
                  source: function (request, response) {
                      $.ajax({
                          type: "POST",
                          //contentType: "application/json; charset=utf-8",
                          url: "AutoCompleteTextBox.aspx/getUserNames",
                          data: "{'TextBoxVal':'" + document.getElementById('&lt;%=txtName.ClientID%&gt;').value + "'}",
                          dataType: "json",
                          success: function (data) {
                              alert("success");
                          },
                          error: function (result) {
                              alert("error ");
                          }
                      });
                  }
              });
          });
  
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;table&gt;
      &lt;tr&gt;
      &lt;td&gt;
      &lt;div&gt;
      User Name : &amp;nbsp;&amp;nbsp;
          &lt;asp:TextBox ID="txtName" runat="server" &gt;&lt;/asp:TextBox&gt;
      &lt;/div&gt;
      &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>AutoCompleteTextBox.aspx.cs :</p>
  
  <pre><code>public List&lt;string&gt; getUserNames(string TextBoxVal)
      {
          string strCon;
          List&lt;string&gt; objList = new List&lt;string&gt;();
          strCon = ConfigurationManager.ConnectionStrings["EmpNameFetch"].ConnectionString;
          SqlConnection con = new SqlConnection(strCon);
          SqlCommand cmd = new SqlCommand(@"select EmpName from newTb2 where EmpName like '%"+TextBoxVal+"%'", con);
          con.Open();
          SqlDataReader objReader = cmd.ExecuteReader();
  
          while (objReader.Read())
          {
              objList.Add(objReader["EmpName"].ToString());
          }
          Response.Write(objList.ToString());
          con.Close();
          return objList;
  
      }
  </code></pre>