自动完成扩展器的网络服务不起作用
我使用了ajax自动扩展器,代码就像as
<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自动扩展器不起作用
I have use ajax auto extender the code is like as
<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>
and web services In Autocomplete.asmx is that the web service is not calling
[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));
}
but ajax auto extender is not working
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用上面所需的方法
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
U have to use the following above ur required method
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]