如何使用JavaScript填充Ajax自动完成扩展器 [英] How to Populate Ajax-Autocomplete Extender using javascript
问题描述
我有一个自动完成扩展器.我正在使用Web方法填充它
//------------------------------------------------ ------------------
< asp:TextBox ID ="txtTestCode" runat ="server">
I have an auto complete extender . I am populating it using Web method
//------------------------------------------------------------------
<asp:TextBox ID="txtTestCode" runat="server">
<cc1:AutoCompleteExtender ID="AutoCompleteExtenderDemo" runat="server"
TargetControlID="txtTestCode" ServiceMethod="GetCompletionList"
MinimumPrefixLength="1" CompletionInterval="1000"
EnableCaching="true" CompletionSetCount="5">
</cc1:AutoCompleteExtender>
/------------------------------------------------- --------------------
/---------------------------------------------------------------------
[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;
}
//------------------------------------------------ --------------------
有没有办法使用javascript在客户端填充它?
//--------------------------------------------------------------------
Is there any way to populate it at clientside using javascript
推荐答案
IMO,如果要这样做,应该尝试使用jQuery自动完成插件使用Javascript.该控件旨在与Web服务一起使用.
http://docs.jquery.com/Plugins/autocomplete [
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[^]
这篇关于如何使用JavaScript填充Ajax自动完成扩展器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!