0

I have created a web service in .net which will retrieve the city name based on the given input text. The web service is working properly. I have used that web service in an AutoCompleteExtender Control in ajax control toolkit. But i am not getting the list of suggestions if i type anything in the textbox.

The web service structure is:
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>

What should be the exact ServicePath and ServiceMethod? Whether the css file is necessary to get the output?

4

1 回答 1

0

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

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

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

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

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

如果您不太确定从哪里开始,请查看 Chrome 的开发者工具,尤其是网络面板

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

于 2012-09-20T13:28:55.767 回答