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
- public void ProcessRequest(HttpContext context)
- {
- string term = context.Request["term"] ?? "";
- List<string> listCustomers = new List<string>();
- using (SqlConnection con = DBCS.GetDbCon())
- {
- SqlCommand cmd = new SqlCommand("spGetCustomers", con);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@term", term);
- con.Open();
- SqlDataReader rdr = cmd.ExecuteReader();
- while (rdr.Read())
- {
- listCustomers.Add(rdr["CustomerName"].ToString());
- }
- }
-
- JavaScriptSerializer js = new JavaScriptSerializer();
- context.Response.Write(js.Serialize(listCustomers));
- }
JQuery:
- $(document).ready(function () {
- $('#ContentPlaceHolder1_txtCustomerName').autocomplete({
- source: '/Handler/CustomerPolicyTransHandler.ashx'
- });
- });
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.