Home > AJAX, ASP.Net > AJAX AutoComplete with static data

AJAX AutoComplete with static data

Try this example:

<ajaxtoolkit:autocompleteextender runat="server"
id="AutoCompleteExtender1? enabled="true"
minimumprefixlength="1" servicepath="~/SuggestionService.asmx"
targetcontrolid="txtSearch" />

create webserviece

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Collections.Generic;

/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "<a href="http://tempuri.org/">http://tempuri.org/</a>")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService

    public WebService ()

        //Uncomment the following line if using designed components

    public string[] GetAllNames(string prefixText, int count)
        ArrayList filteredList = new ArrayList();
        string s2 = "\n";
        char[] ch = s2.ToCharArray();
        string[] names ={ "India", "UK", "US", "China", "Nepal" };

        foreach (string name in names)
            if (name.ToLower().StartsWith(prefixText.ToLower()))
        return (string[])filteredList.ToArray(typeof(string));


Good Luck

Categories: AJAX, ASP.Net
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: