Cannot unregister UpdatePanel with ID 'UpdatePanel1' since it was not registered with the ScriptMana

Amit Kasundra asked on June 30, 2014 06:05

I have created blank site. Then registered my custom control as web part. Web part registration get done successfully.

But, unfortunately while I am adding that web part over the page getting an exception.

Exception:

Cannot unregister UpdatePanel with ID 'UpPanelgvMain' 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.

Can anyone have proper solution to fix it?

Looking forward for your quick response.

Thanks You.

Recent Answers


Brenden Kehren answered on June 30, 2014 07:20

Does your webpart have a update panel? Do you hide and show it on page load or do any other actions to it? Most likely an issue with that. When creating a webpart, the whole standard asp.net page life cycle is null and void, in my opinion. What you normally would do in a page load event is now done in the OnContentLoaded() method which is close to OnInit or PreInit. You need to set your properties there so they can be relayed to the underlying controls in the proper page life cycle for them to function properly.

Can you share some code?

0 votesVote for this answer Mark as a Correct answer

Amit Kasundra answered on July 1, 2014 06:33

Hi Brenden,

Thank you for your answer. Actually, I have implement web user control with this methodology only. I mean we are setting up relevant properties in OnContentLoaded() method.

I have applied following two solution to get it done.

Solution 1:

This solution is suggested by Kentico support team.

Instead of using default UpdatePanel use CMSUpdatePanel.

Need to replace <asp:UpdatePanel ID="UpdatePanel1" runat="server"> By <cms:CMSUpdatePanelID="UpdatePanel1" runat="server">

Solution 2:

Add following method in your code behind file and add OnUnload="UpdatePanel_Unload" in UpdatePanel

protected void UpdatePanel_Unload(object sender, EventArgs e) { MethodInfo methodInfo = typeof(ScriptManager).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance) .Where(i => i.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel")).First(); methodInfo.Invoke(ScriptManager.GetCurrent(Page), new object[] { sender as UpdatePanel }); }

<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnUnload="UpdatePanel_Unload">

0 votesVote for this answer Mark as a Correct answer

EM DEV answered on July 3, 2014 15:19

I am also experiencing this update panel issue after upgrading from 7-8. The cms:cmsupdatepanel takes the errors away, but does not function like a regular updatepanel. On top of that, all my custom code using gridviews, detailsviews, etc are acting super wonky. Selectedindexchanged events aren't firing or requiring double clicks to fire, gridviews disappearing on selected event, etc. Events in page_load not firing, moved to page_init and had some progress. It seems like the entire page lifecycle has changed since the upgrade for anything custom. I have been working on it for a day now and any insight would be much appreciated.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.