Hold On

Hold On

  • 1.2k
  • 1k
  • 169.9k

AutoComplete TextBox Having 2 Parameters

Oct 30 2019 9:39 PM
Hello everyone!
 
I was able to create an autocomplete with a single parameter only using a generic handler and jquery. Below is my code snipet:
 
Generic handler 
  1. public void ProcessRequest(HttpContext context)  
  2.         {  
  3.             string term = context.Request["term"] ?? "";  
  4.             List<string> listCustomers = new List<string>();  
  5.             using (SqlConnection con = DBCS.GetDbCon())  
  6.             {  
  7.                 SqlCommand cmd = new SqlCommand("spGetCustomers", con);  
  8.                 cmd.CommandType = CommandType.StoredProcedure;  
  9.                 cmd.Parameters.AddWithValue("@term", term);  
  10.                 con.Open();  
  11.                 SqlDataReader rdr = cmd.ExecuteReader();  
  12.                 while (rdr.Read())  
  13.                 {  
  14.                     listCustomers.Add(rdr["CustomerName"].ToString());  
  15.                 }  
  16.             }  
  17.   
  18.             JavaScriptSerializer js = new JavaScriptSerializer();  
  19.             context.Response.Write(js.Serialize(listCustomers));  
  20.         }  
 JQuery:
  1. $(document).ready(function () {  
  2.            $('#ContentPlaceHolder1_txtCustomerName').autocomplete({  
  3.                source: '/Handler/CustomerPolicyTransHandler.ashx'  
  4.            });  
  5.        });  
Now, I need to create another autocomplete but this time there are 2 parameters. My problem is on the jquery side. How can do that in my jquery?
 
Thanks in advance for any assistance. 

Answers (1)