[英]webservices for Autocomplete extender is not working
我已經使用了ajax自動擴展器,代碼就像
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div>
<asp:TextBox ID="txt_AutoComplete" runat="server" Width="200"></asp:TextBox>
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1"
ServiceMethod="GetNames" ServicePath="~/AutoComplete.asmx" TargetControlID="txt_AutoComplete"> </asp:AutoCompleteExtender>
和Web服務在Autocomplete.asmx中是Web服務未調用
[WebMethod]
public string[] GetNames(string prefixText, int count)
{
ArrayList sampleList = new ArrayList();
sampleList.Add("ABC"); sampleList.Add("Hello");
sampleList.Add("Hi");
sampleList.Add("Hey");
ArrayList filteredList = new ArrayList();
foreach (string s in sampleList)
{
if (s.ToLower().StartsWith(prefixText.ToLower()))
filteredList.Add(s);
}
return (string[])filteredList.ToArray(typeof(string));
}
但是ajax自動擴展器不起作用
您必須使用以下您要求的以下方法
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.