2010-11-01 165 views
1

我看過this link,我試過了所有的建議,但是我的Asp.Net AJAX自動完成仍然無法工作。 aspx頁面上ASP.Net AJAX自動完成不工作

<asp:ToolkitScriptManager ID="ScriptManager" runat="server"> 
</asp:ToolkitScriptManager> 
<asp:Label ID="FieldLabel" Text="Label:" runat="server"></asp:Label> 
<asp:TextBox ID="InputField" runat="server"></asp:TextBox> 
<asp:AutoCompleteExtender 
    ID="Autocompleter" 
    TargetControlID="InputField" 
    ServiceMethod="GetCompletionList" 
    ServicePath="~/TestWebService.asmx" 
    MinimumPrefixLength="1" 
    CompletionInterval="1000" 
    runat="server"> 
</asp:AutoCompleteExtender> 

我沒有任何後臺代碼:

我只有一個標籤一個測試項目,文本框的自動完成者。在TestWebService.asmx.cs,我有:

[System.Web.Services.WebMethod] 
[System.Web.Script.Services.ScriptMethod] 
public string[] GetCompetionList(string prefixText, int count) 
{ 
    string[] results = { "test", "test", "test" }; 
    return results; 
} 

從理論上講,我的文本框應該包含「測試」一詞的3個實例自動完成下拉列表。在實踐中,我可以在文本框中輸入任何我想要的東西,但什麼都不會發生。有誰知道我做錯了什麼?

+0

相同的代碼,我試過但沒有爲我工作。任何其他設置都需要更改。 – siri 2011-08-19 05:49:42

回答

0

我想通了。我拼錯了WebMethod的名字。如果你注意到,它的「GetCompetionList」,而不是「GetCompletionList」。

現在一切正常。

0

它看起來好像你的Web服務方法缺少一個參數。另外,請確保您爲自動完成「下拉式」設置了正確的樣式。換句話說,將您的代碼與the reference進行比較。

+1

真正的問題是我無法拼寫。請參閱下面的答案。 – quanticle 2010-11-01 16:04:42

0

你應該在你的代碼

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

public static string[] GetCompetionList(string prefixText, int count) 

{ 
    string[] results = { "test", "test", "test" }; 


    return results; 

} 
0

我面臨的問題similiar和被刪除的web.config文件中這些行解決公共使用後

字(靜態)。

<rules> 
     <rule name="san aspx"> 
      <!--Removes the .aspx extension for all pages.--> 
      <match url="(.*)"/> 
      <conditions logicalGrouping="MatchAll"> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" />  
      </conditions> 
      <action type="Rewrite" url="{R:1}.aspx"/> 
     </rule> 
     </rules>