我使用ajax auto extender代码就像
<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 auto extender无效
答案 0 :(得分:0)
你必须使用以上所需方法
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]