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

Problem with RadDock Codebehind Processing

2 Answers 42 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 02 Aug 2013, 04:13 PM
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.Tag=panelID+","+controlType;
        dock.Title=panelTitle;
        dock.Text=panelDescription;
        dock.Width=Unit.Percentage(100);
        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)
            {
                
                source=dock.Tag;
                parsed=source.Split(',');
                panelid=parsed[0];
                paneltype=parsed[1];
                WorkspacePanel.PanelID=Convert.ToInt32(panelid);
                WorkspacePanel.PanelLocation=panellocation;
                WorkspacePanel.WorkspaceID=workspaceid;
                
            }//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 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 06 Aug 2013, 08:54 AM
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>
    <telerik:RadDockZone runat="server" ID="RadDockZone2" CssClass="second" Width="300px">
    </telerik:RadDockZone>
</telerik:RadDockLayout>
<asp:Button ID="Button1" Text="postback" OnClick="Button1_Click" runat="server" />
<asp:Label ID="Label1" Text="" runat="server" />
.first
{
    background-color: Gray;
}
.second
{
    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");
    RadDockLayout1.Controls.Add(dock);
    dock.Tag = "tag1";
    dock.Title = "panelTitle";
    dock.Text = "panelDescription";
    dock.Width = Unit.Percentage(100);
    dock.Commands.Add(new DockExpandCollapseCommand());
    dock.Dock(RadDockZone1.ClientID);
}
 
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;
}



Regards,
Marin Bratanov
Telerik
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.
0
Michael
Top achievements
Rank 1
answered on 06 Aug 2013, 03:27 PM
That was it...thank you!
Tags
Dock
Asked by
Michael
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Michael
Top achievements
Rank 1
Share this question
or