2012-09-20 41 views
0

我在.net中創建了一個基於給定輸入文本的城市名稱。 Web服務正常運行。我在ajax控件工具包的AutoCompleteExtender控件中使用了該Web服務。但是,如果我在文本框中輸入任何內容,我都不會收到建議列表。ajax控件工具包中的AutoCompleteExtender控件

Web服務結構是:
公共字符串GetCompletionList(字符串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文件?

回答

0

看看官方文檔,here。它表示該服務方法的簽名必須符合下列條件:

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

所以,我想通過添加一個方法與此簽名,以現有的Web服務開始。

另外,我建議你利用一些基於瀏覽器的工具(腳本調試,調試HTTP等),以確保:

  1. 沒有JavaScript錯誤,你的網頁
  2. 上發生您的Ajax請求成功到達
  3. 恰當的反應正在從服務返回的服務器

如果你不太知道從哪裏開始,看看Chrome的d eveloper Tools,尤其是Network Panel

就您當前的配置而言(ServicePath,ServiceMethod等),一切看起來都適合我。

相關問題