Cannot unregister updatepanel since it was not registered with the scriptmanager error

Cannot unregister updatepanel since it was not registered with the scriptmanager error

This error is a pesky one. You will most likely encounter it when you’re trying to dynamically load an UpdatePanel within an itemTemplate in a datagrid, or some similar control with dynamically created items. In my case: in a datagrid, and specifically within an item template in that grid. Here is the solution that has worked for me:

1) Hook into the Unload event of the updatepanel like so (in ASPX or ASCX file):

<asp:UpdatePanel runat="server" ID="updatePanel" OnUnload="updatePanel_Unload">

2) Now in your code behind, use this implementation of Unload.
(*You will need a reference to System.Linq and System.Reflection if you don’t already have one)

protected void updatePanel_Unload(object sender, EventArgs e)
    /* Cast sender as an updatePanel, and use reflection to invoke
     * * the page's scriptmanger registerUpdatePanel() method
     * * */
    UpdatePanel aUpdatePanel = sender as UpdatePanel;

    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(ScriptManager.GetCurrent(aUpdatePanel.Page), new object[] { aUpdatePanel });

Executing the reflection code to invoke the scriptManager’s registerUpdatePanel() method should fix your problem and you’re off and running again!

There are 4 comments .

Scott —

This saved my behind. I’m not sure when it was posted but thanks a million! I could not figure out this damn error…

Reply »

I like your solution. I’ve always wondered though, there is probably a good reason why MS doesn’t want us to move an UpdatePanel to another parent. How can we be sure that hacks like these don’t break stuff in the background?

Reply »
Edwin —

You are my hero of the day!

Reply »
Mohammad —

Thank you for, but I think that your solution get new problem with Ajax Extenders.:

Error: Sys.WebForms.PageRequestManagerServerErrorException: Extender controls may not be registered after PreRender.

Reply »

Share Your Thoughts!


What My Clients Say

Karin - Hope and Future

Brent has always been very prompt and generally exceeds our expectations with his work. His maintenance fee is very reasonable. I strongly recommend him!  We get many compliments on our beautiful web site!


I contacted Krueger Web Design and Brent did everything.  He setup a test site with the changes so we could verify everything was correct before we transferred from my old hosting provider.  During the setup and conversion Brent was extremely professional and responsive. He responded to any issues the same day.

Dan Kaufman
Emily - GFCLT

We've had a great experience working with Krueger Web Design. Prompt responses, great ideas, effective work... all at a reasonable price! This was the perfect fit for our organization.

Mahmud - ACMC

I would love to recommend you to anyone! You have been very helpful when we needed you the most.

Brian - SEMNIC

Working with Krueger Web Design was effortless. Communicating what I wanted for the website and the results that I saw were identical. The customer service was always prompt and I am completely satisfied with the product.

Zach - Stadium Club

Exactly what I wanted! Fast turnaround time and very affordable. Answered all of our questions quickly and made adjustments promptly. Very easy to work with and puts everything into terminology that even I can understand!

Contact Krueger Web Design

Have a question for me? Need an estimate on some work? You can email me at or drop me a line using the button below:

Copyright © 2018 Krueger Web Design - All rights reserved
Web Design in Madison, WI