2010-11-01 132 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>