Ajax Autocompleteextender 不显示可供选择的自动完成列表

发布于 2024-08-30 03:45:38 字数 1771 浏览 10 评论 0原文

我正在使用 asp.net 和 c#.net 中的文本框使用 ajax autocompleteextender。我无法获得可供选择的列表,我有适当的网络服务方法称为..任何人都可以指导我完成自动操作。

<form id="form1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <div>
    <asp:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="TextBox1"
    ServiceMethod="GetCompletionList"
    ServicePath="AutoComplete.asmx"
    MinimumPrefixLength="0" 
    CompletionInterval="50"
    EnableCaching="true"
    CompletionSetCount="1"    
    DelimiterCharacters=";, :"
    ShowOnlyCurrentWordInCompletionListItem="true">        
</asp:AutoCompleteExtender>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </div>
    </form>

Web服务方法包含以下代码

[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class AutoComplete : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {
            List<string> responses = new List<string>();

            for (int i = 0; i < count; i++)

                responses.Add(prefixText + (char)(i + 65));
            return responses.ToArray();
        }
    }

i was working ajax auto completeextender witha text box in asp.net and c#.net. i am not able to get list to choose ,i have the appropriate web service method called..can anyone guide me to get the automo complete done.

<form id="form1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <div>
    <asp:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="TextBox1"
    ServiceMethod="GetCompletionList"
    ServicePath="AutoComplete.asmx"
    MinimumPrefixLength="0" 
    CompletionInterval="50"
    EnableCaching="true"
    CompletionSetCount="1"    
    DelimiterCharacters=";, :"
    ShowOnlyCurrentWordInCompletionListItem="true">        
</asp:AutoCompleteExtender>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </div>
    </form>

and the web service method contains the following code

[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class AutoComplete : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {
            List<string> responses = new List<string>();

            for (int i = 0; i < count; i++)

                responses.Add(prefixText + (char)(i + 65));
            return responses.ToArray();
        }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

垂暮老矣 2024-09-06 03:45:38

您的方法需要具有以下两个属性

[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod()]

Your method needs to have the following two attirubutes

[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod()]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文