Greetings!
I'm developing a little Web application and use the RadDock as my base classes. I override OnPreRender and Render for RadDockZone.
What I'm trying to do is dynamically add the RadDockLayout based on a column structure; I mean, I have a button to add a RadDockLayout to my default ASP.NET page, and I pass a column count, with this I create my RadDockZones. If I pass 2 columns, the RadDockLayout will have 2 RadDockZones. Everything is fine here, the problem comes when I want to add a RadDock to any of my RadDockZones. I use this as guide to my code.
- The page is loaded, then I type the Id of the RadDockLayout and asign it a number of columns, then I click the button and create them. The RadDockLayout is inside an UpdatePanel (updater). The zones are shown in the page fine.
- I add a RadDock to any zone and when goes to the OnPreRender in my RadDockZone derived class it throws the exception.
When I'm debugging and reach for the overriden OnPreRender in the RadDockZone derived class, in the line of base.OnPreRender( e ), it throws a System.InvalidOperationException: Script controls may not be registered after PreRender.
Here is some code in the RadDockZone derived class:
protected
override void OnPreRender( EventArgs e )
{
if ( !DesignMode )
{
ScriptManager scriptManager = ScriptManager.GetCurrent( base.Page );
if ( scriptManager == null )
throw new HttpException();
scriptManager.RegisterScriptControl( this );
}
base.OnPreRender( e ); // The exception occurs here, after I add a RadDock.
}
Code in the Default.aspx.cs:
protected
void btnAddRdDockDerived_Click( object sender, EventArgs e )
{
var rdLayoutDerived = PageState;
var rdDockDerived= CreateRdDockDerived( txtRddDerivedName.Text );
rdLayoutDerived.Zones[0].DocksDerived.Add( widget );
rdDockDerived.Dock( rdLayoutDerived.Zones[0] );
CreateSaveStateTrigger( widget );
PageState = rdLayoutDerived ;
}
protected
override void OnPreRender( EventArgs e )
{
base.OnPreRender( e );
var rdLayoutDerived = PageState;
if ( rdLayoutDerived != null )
{
updater.ContentTemplateContainer.Controls.Add( rdLayoutDerived );
PageState = rdLayoutDerived ;
}
}
PageState is a property that saves the RadDockLayout and its children in the session.
I thank to any help that anyone can give me.