What causes the 'Cannot unregister UpdatePanel

2020-02-10 15:13发布

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?

8条回答
一纸荒年 Trace。
2楼-- · 2020-02-10 15:29

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

查看更多
【Aperson】
3楼-- · 2020-02-10 15:30

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);
}
查看更多
叛逆
4楼-- · 2020-02-10 15:39

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.

查看更多
家丑人穷心不美
5楼-- · 2020-02-10 15:40

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.

查看更多
我只想做你的唯一
6楼-- · 2020-02-10 15:43

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

查看更多
Deceive 欺骗
7楼-- · 2020-02-10 15:44

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

查看更多
登录 后发表回答