2012-02-21 137 views
0

我使用了Ajax的自动扩展的代码是这样的web服务的自动完成功能扩展不工作

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> 
    </asp:ToolkitScriptManager> 
    <div> 
    <asp:TextBox ID="txt_AutoComplete" runat="server" Width="200"></asp:TextBox> 
    <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1" 
    ServiceMethod="GetNames" ServicePath="~/AutoComplete.asmx" TargetControlID="txt_AutoComplete"> </asp:AutoCompleteExtender> 

和Web服务Autocomplete.asmx是Web服务并不是要求

[WebMethod] 

     public string[] GetNames(string prefixText, int count) 
     { 
      ArrayList sampleList = new ArrayList(); 

      sampleList.Add("ABC"); sampleList.Add("Hello"); 

      sampleList.Add("Hi"); 

      sampleList.Add("Hey"); 

      ArrayList filteredList = new ArrayList(); 
      foreach (string s in sampleList) 
      { 

       if (s.ToLower().StartsWith(prefixText.ToLower())) 

        filteredList.Add(s); 

      } 
      return (string[])filteredList.ToArray(typeof(string)); 

     } 

但AJAX自动延长工作不

+0

它是否给一个错误?什么?请显示您的asmx.cs的完整代码 – Shai 2012-02-21 13:43:08

+0

该方法不起作用 其不调用网络方法 – 2012-02-21 13:44:19

+0

它根本不调用Web方法? – Shai 2012-02-21 13:45:14

回答

0

u必须使用上面乌尔所需的方法如下

[System.Web.Services.WebMethod]

[System.Web.Script.Services.ScriptMethod]

相关问题