12

我有一个包含 UpdatePanel 的 UserControl。当我把它放在页面上时,它会引发以下错误:

无法取消注册 ID 为“ReviewContentUpdatePanel”的 UpdatePanel,因为它未在 ScriptManager 中注册。如果从控件树中删除 UpdatePanel 并稍后再次添加,则可能会发生这种情况,这是不受支持的。参数名称:更新面板

ReviewContentUpdatePanel是更新面板的名称,它没有被删除或添加到代码中,它存在于 aspx 页面中并且没有被删除。有没有人遇到过这个?

4

8 回答 8

5

This error occurs when the Controls collection in which the UpdatePanel is resided is cleared using the Clear method, or when the specific UpdatePanel is removed using the Remove method.

A trigger for these methods could be the implementation of the CreateChildControls method for the control contains the UpdatePanel. Usually, you call Controls.Clear() in the top of this method, to start with a clean slate if this method is called repeatedly.

于 2009-02-24T03:02:55.200 回答
4

Are you moving controls about in code? If so take a look here and see if this solves your problem.

于 2008-10-27T15:10:18.613 回答
3

我以前也有过这种情况。为了修复它,我只是删除了它,然后重新创建它,问题就消失了。

于 2009-02-24T15:47:58.450 回答
3

我希望这对其他人有帮助,因为它让我发疯了。在在这里和其他地方找到各种信息后,我终于想出了以下修复方法。请注意,我不是在此处或其他任何地方动态创建此更新面板,并且大多数信息都与动态创建此控件有关,而我不是。

我在使用脚本管理器的母版页继承的页面上使用的 Web 用户控件内使用更新面板。我不知道这个组合是否是导致它的原因,但这就是我修复它的方法(在使用更新面板的 Web 用户控件内):

protected override void OnInit(EventArgs e)
{
    ScriptManager sm = ScriptManager.GetCurrent(this.Page);
    MethodInfo m = (
    from methods in typeof(ScriptManager).GetMethods(
        BindingFlags.NonPublic | BindingFlags.Instance
        )
    where methods.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel")
    select methods).First<MethodInfo>();

    m.Invoke(sm, new object[] { updatePanel });
    base.OnInit(e);
}
于 2013-09-25T13:27:02.760 回答
2

在您的标记中,确保您已为 UpdatePanel 及其父层次结构中的每个 runat="server" 控件指定了一个 ID。

于 2009-02-10T15:42:33.163 回答
0

您是否尝试过在用户控件中包含 ScriptManagerProxy?

于 2009-02-27T21:21:24.507 回答
0

Try to remove the scriptproxy of UserControl. In this case you only have a ScriptManager on your page.

于 2009-05-19T19:00:15.717 回答
0

这有点远,但我有过使用 AJAX 扩展的经验,特别是更新面板,其中子控件引发的错误表现为更新面板引发的不同错误。由于子控件中的错误,我确实看到了对这个特定错误的引用:

http://msmvps.com/blogs/shareblog/archive/2009/03/11/cannot-unregister-updatepanel-with-id-since-it-was-not-registered-with-the-scriptmanager-and-moss。 aspx

不确定您是否属于这种情况,但因此我花了很多时间来追查错误的错误。

于 2009-06-05T19:33:32.943 回答