Jquery – Autocomplete extender in Ajax Toolkit and JQuery limiting to “Starts with”


There are many flavours to the AutoComplete implementation, I first did a WPF implementation that was very robust, each entry took keywords, so when searching for an employee, it didn't matter if you typed the first or last name, the results came back similar to Google Suggest.

What I have found limiting in both the JQquery autocomplete and the ASP.Net Autocomplete extender is that there is no keyword search, or contains functionality, it simply uses a "Startswith" type search.

For example, in order to Search for "Mark Adams" as a staff name, you have to type in M,a,r, etc. If you typed in A,d, etc, no result would return.

Does anyone know of plans for this? Is there anything out there right now?

Best Solution

You must have missed jquery autocomplete option like


It does exactly what you want. It would match for Mark Adams, when you type A,d etc.


And for ajaxtoolkit AutoCompleteExtender, i fear you don't get any option equivalent of matchContains in jquery. But you can do it easily in service method. Set it as...


where GetNameList contains the whole logic of how to match the data. E.g.

public partial class _Default : System.Web.UI.Page {
    public static string[] GetNameList(string prefixText, int count) {
        string sql = String.Format("select name from customers where name like @given_name");

        List<string> nameList = new List<string>();
        using (SqlConnection connection = new SqlConnection("Integrated Security=SSPI;Initial Catalog=Northwind;Data Source=."))
        using (SqlCommand command = new SqlCommand(sql, connection)) {
            command.Parameters.AddWithValue("@given_name", "%"+prefixText"%");
            using (SqlDataReader reader = command.ExecuteReader()) {
                while (reader.Read()) {

        return nameList.ToArray();

The below is the code line, which does the matching.

command.Parameters.AddWithValue("@given_name", "%"+prefixText"%");