Click here to Skip to main content
15,898,374 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have an auto complete extender . I am populating it using Web method
//------------------------------------------------------------------
<asp:TextBox ID="txtTestCode" runat="server">
XML
<cc1:AutoCompleteExtender ID="AutoCompleteExtenderDemo" runat="server"
            TargetControlID="txtTestCode" ServiceMethod="GetCompletionList"
            MinimumPrefixLength="1" CompletionInterval="1000"
            EnableCaching="true" CompletionSetCount="5">
        </cc1:AutoCompleteExtender>

/---------------------------------------------------------------------

C#
[System.Web.Services.WebMethod]
       public static string[] GetSuggestions(String prefixText, int count)
       {
           string[] movies = { "RGL", "CYT", "SPL", "URN", "HEM", "BIO", "STL" };

           ArrayList filteredList = new ArrayList();

           foreach (string s in movies)
          {
              if (s.ToLower().StartsWith(prefixText.ToLower()))
              filteredList.Add(s);
          }
          return (string[])filteredList.ToArray(typeof(string));
       }

       [System.Web.Services.WebMethod]
       public static string[] GetCompletionList(String prefixText, int count)
       {
           string[] suggetions = GetSuggestions(prefixText, count);
           return suggetions;
       }


//--------------------------------------------------------------------

Is there any way to populate it at clientside using javascript
Posted

1 solution

IMO, you should try the jQuery autocomplete plugin if you want to do it using Javascript. That control was designed to be used with a Web Service.

http://docs.jquery.com/Plugins/autocomplete[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900