【问题标题】:AutoCompleteExtender Control in ajax control toolkitajax 控件工具包中的 AutoCompleteExtender 控件
【发布时间】:2012-09-20 12:32:18
【问题描述】:

我在 .net 中创建了一个 Web 服务,它将根据给定的输入文本检索城市名称。 Web 服务工作正常。我在 ajax 控件工具包中的 AutoCompleteExtender 控件中使用了该 Web 服务。但是,如果我在文本框中输入任何内容,我就不会得到建议列表。

网络服务结构是:
public string GetCompletionList(string prefixText)

<body>
    <form id="form1" runat="server">
<div>
<!--.........................................
.........................................
.........................................-->
<asp:TextBox ID="txtsearchcity" runat="server" class="autosuggest"></asp:TextBox>
<asp:AutoCompleteExtender runat="server" 
        ID="autoComplete1" 
        TargetControlID="txtsearchcity" 
        ServicePath="http://localhost:3935/SearchCity/searchcity.asmx" 
        ServiceMethod="GetCompletionList"
        MinimumPrefixLength="2"
        CompletionInterval="1000" 
        EnableCaching="true" 
        CompletionSetCount="20">
</asp:AutoCompleteExtender>
<!--.........................................
.........................................
.........................................-->
</div>
</form>
</body>

确切的 ServicePath 和 ServiceMethod 应该是什么? 获取输出是否需要css文件?

【问题讨论】:

    标签: html asp.net ajaxcontroltoolkit


    【解决方案1】:

    查看官方文档here。它表示服务方法的签名必须与以下内容匹配:

    public string[] GetCompletionList(string prefixText, int count)
    

    所以,我将首先将具有此签名的方法添加到您现有的 Web 服务中。

    另外,我建议您利用一些基于浏览器的工具(脚本调试、http 调试等)来确保:

    1. 您的网页上没有发生 javascript 错误
    2. 您的 ajax 请求已成功到达服务器
    3. 服务正在返回正确的响应

    如果您不确定从哪里开始,请查看 Chrome 的开发者工具,尤其是 Network Panel

    就您当前的配置(ServicePath、ServiceMethod 等)而言,我认为一切都已到位。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多