Search code examples
jqueryvisual-studio-2008autocompleteashx

jQuery show more results


I am using jQuery Autocomplete, not jQueryUI, and currently it will not show more than 10 results. I have indicated max:20 to try it out but to no avail. Is it because of my query limit?

Javascript

$(document).ready(function() {
        $("#<%=txtSearch.ClientID%>").autocomplete('Autocomplete/Search_CS.ashx', {width: 400, multiple: false, matchContains: true, delay: 200, Max: 20 });
    });

ASHX

public class Search_CS : IHttpHandler {

public void ProcessRequest (HttpContext context) {
    string prefixText = context.Request.QueryString["q"];
    using (SqlConnection conn = new SqlConnection())
    {
        conn.ConnectionString = ConfigurationManager
                .ConnectionStrings["Rollup2ConnectionString"].ConnectionString;
        using (SqlCommand cmd = new SqlCommand())
        {
            //cmd.CommandText = "select NUID from T_USER where " +
            //"NUID like @SearchText + '%'";
            cmd.CommandText = "select rtrim(NUID) NUID, rtrim(FNAME) FNAME, rtrim(LNAME) LNAME from T_USER where NUID like @SearchText + '%' OR FNAME like @SearchText + '%' OR LNAME 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["NUID"].ToString() + " ").Append(sdr["FNAME"].ToString() + " ").Append(sdr["LNAME"].ToString() + " ")
                        .Append(Environment.NewLine); 

                }
            }
            conn.Close();
            context.Response.Write(sb.ToString()); 
        }
    }
}

public bool IsReusable {
    get {
        return false;
    }
}
}

Solution

  • Its max not Max

    $("#<%=txtSearch.ClientID%>").autocomplete('Autocomplete/Search_CS.ashx', {width: 400, multiple: false, matchContains: true, delay: 200, max: 20 });