Problem with RadDock Codebehind Processing

3 posts, 0 answers
  1. Michael
    Michael avatar
    43 posts
    Member since:
    Mar 2013

    Posted 02 Aug 2013 Link to this post

    I am creating a raddock dynamically in the following manner.

    RadDock dock=new RadDock();
            dock.DockMode = DockMode.Docked;
            dock.ID= string.Format("RadDock{0}", Guid.NewGuid().ToString().Replace('-', 'a'));
            dock.Commands.Add(new DockExpandCollapseCommand());

    Upon a postback enabled button click I am trying to cycle through all the raddocks in a dock zone. In the following manner.

    foreach(RadDock dock in dockzone.Docks)
                }//End For-Each

    The issue I am having is unless the raddock set to AutoPostback=true, the Raddock cannot be found in the dockzone. I do not want to do a post back everytime I move the raddock from dockzone to dockzone, what am I doing wrong?

  2. Marin Bratanov
    Marin Bratanov avatar
    3899 posts

    Posted 06 Aug 2013 Link to this post

    Hi Michael,

    Here are the issues I can see with this approach:
    1) the control is created dynamically, but its ID is not the same each time. This means that upon postback the control will not be recreated properly, i.e. it will not be the same control and its settings will not be restored from the ViewState
    2) I do not see a RadDockLayout where the dynamic docks can be added to

    Here is a small sample that seems to work fine for me:
    <telerik:RadDockLayout runat="server" ID="RadDockLayout1">
        <telerik:RadDockZone runat="server" ID="RadDockZone1" CssClass="first" Width="300px">
        <telerik:RadDockZone runat="server" ID="RadDockZone2" CssClass="second" Width="300px">
    <asp:Button ID="Button1" Text="postback" OnClick="Button1_Click" runat="server" />
    <asp:Label ID="Label1" Text="" runat="server" />
        background-color: Gray;
        background-color: Yellow;
    protected void Page_Init(object sender, EventArgs e)
        RadDock dock = new RadDock();
        dock.DockMode = DockMode.Docked;
        //revert to the original random ID to see how upon postback the dock returns to the original zone I dock it to
        dock.ID = string.Format("RadDock{0}", /*Guid.NewGuid().ToString().Replace('-', 'a')*/"someStaticIdentifier");
        dock.Tag = "tag1";
        dock.Title = "panelTitle";
        dock.Text = "panelDescription";
        dock.Width = Unit.Percentage(100);
        dock.Commands.Add(new DockExpandCollapseCommand());
    protected void Button1_Click(object sender, EventArgs e)
        //I simplified this to emulate the logic
        string tags = "";
        foreach (RadDock dock in RadDockZone2.Docks)
            tags += dock.Tag + "<br/>";
        Label1.Text = tags;

    Marin Bratanov
    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 the blog feed now.
  3. Michael
    Michael avatar
    43 posts
    Member since:
    Mar 2013

    Posted 06 Aug 2013 Link to this post

    That was it...thank you!
Back to Top