是什么原因导致“无法取消注册 UpdatePanel”? 错误?

发布于 2024-07-07 05:00:13 字数 366 浏览 5 评论 0原文

我有一个包含 UpdatePanel 的 UserControl。 当我将其放在页面上时,它会抛出以下错误:

无法使用 ID 取消注册 UpdatePanel 'ReviewContentUpdatePanel' 因为它 没有注册 脚本管理器。 如果 UpdatePanel 已从 控制树,后来再次添加, 这是不支持的。 范围 名称:更新面板

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

I've got a UserControl that contains an UpdatePanel. When I put that on a page, it throws the following error:

Cannot unregister UpdatePanel with ID
'ReviewContentUpdatePanel' since it
was not registered with the
ScriptManager. This might occur if the
UpdatePanel was removed from the
control tree and later added again,
which is not supported. Parameter
name: updatePanel

ReviewContentUpdatePanel is the name of the update panel & it's not being removed or added in code, it exists in the aspx page and isn't removed. Has anyone come across this before?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

随心而道 2024-07-14 05:00:13

当使用 清除方法,或者使用 删除方法

这些方法的触发器可能是 的实现CreateChildControls 方法用于包含UpdatePanel 的控件。 通常,您可以在此方法的顶部调用 Controls.Clear(),以便在重复调用此方法时从头开始。

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.

你没皮卡萌 2024-07-14 05:00:13

您是否在代码中移动控件? 如果是这样,请查看 此处 看看这是否可以解决您的问题。

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

白云悠悠 2024-07-14 05:00:13

我以前也遇到过一次这样的情况。 为了解决这个问题,我只是删除了它,然后重新创建它,问题就消失了。

I had this happen once before. To fix it, I just deleted it and then re-created it and the problem went away.

诠释孤独 2024-07-14 05:00:13

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

我在 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);
}

I hope this helps someone else as it drove me nuts. After finding various tidbits of info here and there on here and elsewhere, I finally came up with the following fix. Note, I am not dynamically creating this update panel here or anywhere else and most info out there was related to creating this control dynamically, which I was not.

I was using an update panel inside a web user control used on a page inherited by a master page with the script manager. I don't know if this combo was what was causing it, but this is how I fixed it (inside the web user control where the update panel is utilized):

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);
}
瞎闹 2024-07-14 05:00:13

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

In your markup, make sure you've specified an ID for both UpdatePanels and for every runat="server" control in their parent hierarchies.

暖风昔人 2024-07-14 05:00:13

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

Have you tried including a ScriptManagerProxy in the user control?

暮年 2024-07-14 05:00:13

尝试删除UserControl的scriptproxy。 在这种情况下,您的页面上只有一个 ScriptManager。

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

我很坚强 2024-07-14 05:00:13

这有点遥远,但我有过 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

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

This is a bit of a long shot, but I've had experiences with the AJAX extensions, specifically with the update panel, in which errors thrown by child controls were manifesting themselves as a different error thrown by the update panel. I did see a reference to this specific error being thrown due to an error in a child control:

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

Not sure if this is the case for you or not, but I've spent many hours chasing down the wrong errors because of this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文