hi
i am using autocomplete for category but i want to filter the category based on city, so i need to pass two value to http handler from jquery, below code is used for passing single value.
<script type="text/javascript">
$(document).ready(function() {
$("#<%=txtcategory.ClientID%>").autocomplete('searchcategory.ashx');
});
</script>
Http handler Code
<%@ WebHandler Language="C#" Class="searchcategory" %>
using System;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;
public class searchcategory : IHttpHandler {
public void ProcessRequest (HttpContext context) {
string prefixText = context.Request.QueryString["q"];
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["yaazaaconnstring"].ToString();
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select distinct(sub_cat_name) as bus_name from contracts where " +
"sub_cat_name like @SearchText + '%'" +
" union select distinct(cat_name) as bus_name from contracts where " +
"cat_name like @SearchText + '%'";
cmd.Parameters.AddWithValue("@SearchText", prefixText);
cmd.Connection = conn;
StringBuilder sb = new StringBuilder();
conn.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
sb.Append(sdr["bus_name"])
.Append(Environment.NewLine);
}
}
conn.Close();
context.Response.Write(sb.ToString());
}
}
}
public bool IsReusable {
get {
return false;
}
}
}