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

Dynamic RadDock creation problem

3 Answers 103 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Jesmon
Top achievements
Rank 1
Jesmon asked on 20 Mar 2012, 07:49 AM
Hi,
    When I created a dynamic Raddock , showing an error like  "  Telerik.Web.UI.RadDockZone can contain only controls of type Telerik.Web.UI.RadDock " . please help
thanks
Jesmon Joseph

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Mar 2012, 08:38 AM
Hello Jesmon,

Here is the sample code to create RadDock dynamically which worked as expected. Please elaborate your scenario if it doesn't help.
aspx:
<telerik:RadDockZone ID="RadDockZone1" runat="server">
</telerik:RadDockZone>
C#:
protected void Page_Load(object sender, EventArgs e)
{
  RadDock dock = new RadDock();
  dock.ID = "dock1";
  RadDockZone1.Controls.Add(dock);
}

Thanks,
Shinu.
0
Jesmon
Top achievements
Rank 1
answered on 20 Mar 2012, 09:30 AM
Hello Shinu,
                    I am using Telerik.Web.Ui version is 2011.1.519.35.   and taking the sample from telerik demo site for creating the dynamic RadDock.  In CreateRadDock() 
                private RadDock CreateRadDock()
        {
            int docksCount = CurrentDockStates.Count;

            RadDock dock = new RadDock();
            dock.DockMode = DockMode.Docked;
            dock.UniqueName = Guid.NewGuid().ToString().Replace("-", "a");
            dock.ID = string.Format("RadDock{0}", dock.UniqueName);
            dock.Title = "Dock";
            dock.Text = string.Format("Added at {0}", DateTime.Now);
            dock.Width = Unit.Pixel(300);

            dock.Commands.Add(new DockCloseCommand());
            dock.Commands.Add(new DockExpandCollapseCommand());

            return dock;
        }

DockMode showing the error like could not contain the definition for 'DockMode'. same for dock.Commands also
and I just commented these line and executed then showing the compile error like " Telerik.Web.UI.RadDockZone can contain only controls of type Telerik.Web.UI.RadDock   "
please help

Thanks
Jesmon Joseph
0
Slav
Telerik team
answered on 22 Mar 2012, 03:31 PM
Hello Jesmon,

Note that the RadDockZone can contain only RadDock controls. It appears that you are inserting additional elements or controls in the dock zone which results in the encountered error. I would suggest ensuring that you add just a RadDock controls in the RadDockZone. The approach shown in the following code snippet is recommended for docking a dynamically created RadDock:
RadDockLayout1.Controls.Add(dock); // the RadDock is included in the Controls collection of the RadDockLayout
dock.Dock(RadDockZone1); // the dock is inserted in a RadDockZone via its method Dock
 
This method is used for creating and adding the RadDock controls in the online demo Dock / My Portal.

Also, keep in mind that you should create the RadDock controls before the event RadDock.DockPositionChanged, in order to ensure their proper operation, as stated in the help article RadDock Lifecycle. Usually, the best place to do thi is Init.

If you are still unable to resolve the problem after reviewing the presented information, please open a support ticket and send a simple, runnable page that isolates your case so that I can examine it locally and provide a working solution.

Kind regards,
Slav
the Telerik team
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 their blog feed now.
Tags
Dock
Asked by
Jesmon
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jesmon
Top achievements
Rank 1
Slav
Telerik team
Share this question
or