KB's

Cannot unregister UpdatePanel with ID...

Problem
In page Edit mode, the exception "Cannot unregister UpdatePanel with ID..." could be thrown if you have declared an UpdatePanel or a control containing one directly in the markup of the master page.

Solution
T
he best solution is to use Telerik RadAjax suite instead of Microsoft ASP.NET AJAX UpdatePanel. You could find more information about RadAjaxManager and RadAjaxPanel controls in RadAjax for ASP.NET AJAX manual.

Another possible workaround is to create a user control and place the controls you need to ajaxify in it. Then, you should dynamically load the user controls in the master page. The point is to load the user control only on the public side and not in Edit mode of the page:


1. In the master page declare an
appropriate container for the user control:
<asp:Panel ID="ajaxPanel" runat="server"></asp:Panel> 

2. In Page_Load method, check the page mode, and if it is not Edit, instantiate your user control:

protected void Page_Load(object sender, EventArgs e) 
    { 
        CmsPageBase page = (CmsPageBase)this.Page; 
        if (page.PageMode != CmsPageMode.Edit) 
        { 
            this.LoadMyUserControl("~/UserControls/SimpleControl.ascx"this.ajaxPanel); 
        } 
    } 
 
private void LoadMyUserControl(string virtualPath, Control panel) 
    { 
        panel.Controls.Clear(); 
        UserControl MyControl = (UserControl)this.LoadControl(virtualPath); 
        string userControlID = virtualPath.Split('.')[0]; 
        MyControl.ID = userControlID.Replace("/""").Replace("~"""); 
        panel.Controls.Add(MyControl); 
    } 

The full example for the second solution is attached to this article.