adding RadMenu to Dock

4 posts, 0 answers
  1. Joseph
    Joseph avatar
    4 posts
    Member since:
    Feb 2008

    Posted 11 Mar 2008 Link to this post

    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?
  2. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 11 Mar 2008 Link to this post

    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
  3. Joseph
    Joseph avatar
    4 posts
    Member since:
    Feb 2008

    Posted 11 Mar 2008 Link to this post

    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?
  4. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 12 Mar 2008 Link to this post

    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
Back to Top