This is a migrated thread and some comments may be shown as answers.

adding RadMenu to Dock

3 Answers 95 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Joseph
Top achievements
Rank 1
Joseph asked on 11 Mar 2008, 12:44 PM
I'm creating docks dynamically and trying to add a RadMenu, created in code, to the dock content.  I'm receiving the following error:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Script controls may not be registered after PreRender

The code that creates it is very simple:



else if (dockType == "Menu")  
{  
    dock = new RadDock();  
    RadMenu menu = new RadMenu();  
    menu.Items.Add(new RadMenuItem("Home"));  
    menu.Items.Add(new RadMenuItem("Benefits"));  
    menu.Items.Add(new RadMenuItem("Personal"));  
    menu.Items.Add(new RadMenuItem("Custom"));  
    dock.ContentContainer.Controls.Add(menu);  

All other manner of controls and user controls work fine, but this is the first time I'm attempting to dynamically add a telerik control inside the dock.  Anyone know what I'm doing wrong here?

3 Answers, 1 is accepted

Sort by
0
Sophy
Telerik team
answered on 11 Mar 2008, 03:09 PM
Hi Joseph,

The problem you experience may be due to creating RadDock control too late in the Page Life Cycle. At which stage of the page life cycle do you execute the code you have sent us? Please, note that if you want to create RadDock controls dynamically you should do it in the Init event of the page, in order to allow the RadDockLayout to automatically manage their positions. You could create RadDock controls in other events, but you should recreate them in Init when the next postback or AJAX request occurs.
For your convenience, I have attached a sample page containing dynamically created docks. I suggest you also take a look at the Dynamically Created Docks  online example.

In case the suggested above cannot help you solve the problem. Please, open a support ticket and send us a simple running application which reproduces the problem so  that we can test it locally, research the problem and do our best to help you solve it.

Best wishes,
Sophy
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Joseph
Top achievements
Rank 1
answered on 11 Mar 2008, 03:42 PM
I suspected as much.

I have a form that allows you to customize the properties of the dock as well as it's content before creation.  It's built off of your examples so they are being recreated on init.  The dock creation takes place in the OnClick event of a button but the postback is through Ajax - per the examples on your site.

I have no problem adding other types of controls to the content of the dock - the problem only occurs when trying to create new telerik controls and adding to the content during the click event.

Is there a workaround in this scenario?
0
Sophy
Telerik team
answered on 12 Mar 2008, 08:19 AM
Hello Joseph,

Thank you for the provided details about your scenario.

We tried to reproduce the problem you experience using the My Portal online example but replacing the UserControls with menus. However, we were not able to reproduce the problem you describe. You can find attached our testing page. If this cannot help you resolve the issue, please, send us a simple running application which reproduces the problem so that we can take a closer look at your scenario and research the issue. We need your assistance in order to help you.

Best regards,
Sophy
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Dock
Asked by
Joseph
Top achievements
Rank 1
Answers by
Sophy
Telerik team
Joseph
Top achievements
Rank 1
Share this question
or