title: jQuery autocomplete and aspx / json
body: <p>I am fairly new to jQuery and JSON and have run into a problem I haven't been able to solve.  I have a textbox that I would like a user to start typing a person's name and when he/she selects the name, it autopopulates another textbox with their email address.</p>
  
  <p>My code is as follows.  Any help getting this to work would be greatly appreciated.  Thanks so much in advance!</p>
  
  <p>Markup</p>
  
  <pre><code>&lt;input type="text" id="person_name" class="required" /&gt;
  &lt;input type="text" id="person_email_address" class="required email" /&gt;
  </code></pre>
  
  <p>jQuery</p>
  
  <pre><code>$( "input#person_name" ).autocomplete({
      source: "/autoComplete.aspx",
      dataType: "json",
      minLength: 1,
      select: function( event, ui ) {
          //set email textbox to the email field of the selected item.
      }
  });
  </code></pre>
  
  <p>autoComplete.aspx.cs</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      string term = Request.QueryString["term"];
  
      if (!string.IsNullOrEmpty(term))
      {
          string sql = string.Format("select * from users where first_name like '%{0}%' or last_name like '%{0}%'", term);
  
          DataTable dt = GetTable(sql);
  
          foreach (DataRow dr in dt.Rows)
          {
              string name = dr["first_name"].ToString() + dr["last_name"].ToString();
              string email = dr["email"].ToString();
          }
  
          Response.ContentType = "application/json";
          Response.Write("what goes here so i can access both email and name in the select function?");
      }
  }
  </code></pre>