This is a migrated thread and some comments may be shown as answers.
WindowManager UpdatePanel issue
1 Answer 27 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
DvdBrink asked on 22 Jun 2012, 09:16 AM

Hi guys,

I’m having a issue with a RadWindow which contains an UpdatePanel in combination with the RadWindowManager.

When the popup is added during a GET request it throws an error:

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

When I disable the line: “createRadWindow()” it works and the popup is visible.

Why can’t the popup be created during a GET request?

I’ve read this page:

But I use the RadWindowManager because it recreates the RadWindow from the ViewState in a postback request.

In short I have two questions:
How can I fix this issue? I Need the RadWindowManager to recreate my windows so events for controls on these dialogs work properly.
Why does the popup work when created from a postback and not from a get request.

Kind regards,

Below is my sample code

 aspx code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TelerikRadWindowIssue.Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<head runat="server">
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        <asp:UpdatePanel ID="upanel" runat="server" ChildrenAsTriggers=false UpdateMode=Conditional>
                <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        <asp:Button ID="Button1" runat="server" Text="Button" />

CSharp code
using System;
using System.Web.UI;
using Telerik.Web.UI;
namespace TelerikRadWindowIssue
    public partial class Default : System.Web.UI.Page
        protected override void OnInit(EventArgs e)
            Button1.Click += new EventHandler(Button1_Click);
            createRadWindow(); //With this line enabled the page crashes
            //Disable and click on the button, same code, but the window opens correctly
        void Button1_Click(object sender, EventArgs e)
        private void createRadWindow()
            TestWindow window = new TestWindow();
        private class TestWindow : RadWindow
            public TestWindow()
                ContentContainer.Controls.Add(new UpdatePanel() { ID = "test" });
                VisibleOnPageLoad = true;
                Width = 150;
                Height = 150;

1 Answer, 1 is accepted

Sort by
Marin Bratanov
Telerik team
answered on 26 Jun 2012, 09:49 AM

This problem stems from the framework itself as is described in the KB article you have already found. There is a way to work around it, yet the important bit is that the RadWindowManager will not keep the state of the controls inside the RadWindow, but only for the RadWindows themselves. Nevertheless, a simple factory class can add a handler that properly register the update panels you create:
static class DisposableWindowFactory
    //you can add parameters to control the properties of the RadWindow
    public static RadWindow CreateDisposableWindow()
        RadWindow newWindow = new RadWindow();
        UpdatePanel disposableUpdatePanel = new UpdatePanel();
        //used for disposing the update panel properly
        disposableUpdatePanel.Unload += new EventHandler(RegisterUpdatePanel);
        disposableUpdatePanel.ID = "DisposableUpdatePanel";
        newWindow.VisibleOnPageLoad = true;
        newWindow.Width = 150;
        newWindow.Height = 150;
        return newWindow;
    private static void RegisterUpdatePanel(object sender, EventArgs e)
            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((HttpContext.Current.Handler as Page)), new object[] { sender });

and you can use it like this:
private void createRadWindow()
    RadWindow newWnd = DisposableWindowFactory.CreateDisposableWindow();
    //manage your controls here
    (newWnd.ContentContainer.FindControl("DisposableUpdatePanel") as UpdatePanel).ContentTemplateContainer.Controls.Add(myControls); 

Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Asked by
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question