AutoCompleteExtender 没有调用 ServiceMethod

AutoCompleteExtender is not invoking ServiceMethod

包括

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

我的 ASPX 代码

<asp:TextBox ID="txtSearchKey" runat="server" Width="200" AutoPostBack="true" OnTextChanged="txtSearchKey_TextChanged" />
<asp:TextBoxWatermarkExtender ID="weSearchKey" runat="server" Enabled="True" TargetControlID="txtSearchKey" WatermarkText="Enter search criteria" WatermarkCssClass="watermark" />
<asp:AutoCompleteExtender ServiceMethod="SearchOnboardingMembers" MinimumPrefixLength="3" CompletionInterval="100" EnableCaching="false" CompletionSetCount="10" TargetControlID="txtSearchKey" ID="onboardingSearchExtender" runat="server" FirstRowSelected="false" OnClientItemSelected="GetSelectedId" CompletionListCssClass="completionList" CompletionListItemCssClass="listItem"                                CompletionListHighlightedItemCssClass="itemHighlighted" CompletionListElementID="divCompletionListElement" />

我的后端代码

[ScriptMethod()]
[WebMethod]
public static List<string> SearchOnboardingMembers(string prefixText, int count)
    {
        var filteredSearchText = String.Join(",", prefixText.Split(' ').Where(x => x.Length > 2));

       //my code 

        return items;
    }

这段代码在一个页面上运行良好,我需要在不同的页面上使用相同的功能。我只是将粘贴的 HTML 和后端代码复制到新的 ASPX 文件中。但是,奇怪的是它在该页面上不起作用。当我的意思是不工作时,WebMethod 没有在该页面上被调用。我们有什么办法可以调试这里的问题吗?当我在文本框中键入时,我在任何地方都看不到任何错误或警告,但它没有调用 WebMethod。感谢任何建议

我不知道为什么,但这是我得到的解决方案。

不知何故,ASP.NET 不会从不同的页面调用相同的 WebMethod。最初我将 Web 方法从一个页面复制/粘贴到另一个页面的代码后面;正如我在此处的问题中所述,从未在 UI 上调用第二页函数。

我将此 WebMethod 移动到基页 class 并且它在两个页面中都有效!!它可能与两个页面后面的代码中使用的名称相同,它之前没有工作。