Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Docking > Restore the Existing Docks after draging from usercontrol in Radwindow to other page dock zone
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Restore the Existing Docks after draging from usercontrol in Radwindow to other page dock zone

Feed from this thread
  • sridharreddy avatar

    Posted on Nov 8, 2010 (permalink)

    I created one user control with 3 docks (code:1- user control aspx, 2- user control .CS  and I created one aspx page with following with radwindow to load user control and one buttion to  popup the radwindow  one radlayout  and Zone to drag the dock from rad windiows to here (3- main page aspx ,4- main page cs ). Here I am able drag and drop dock also and also I am creating new dock and adding to draged zone. But I need while draging dock from usercontrol  in to other page zone, it 's create new instance and added to droped zone  and I need same state in user controls before draging it.

    Code 1user Control aspx):

    <%

    @ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl.ascx.cs" Inherits="webapp.WebUserControl" %>

     

    <%

    @ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

     

    <

     

    script language="javascript" type="text/javascript" >

     

    </

     

    script>

     

    <

     

    telerik:RadDockLayout ID="layout1" runat="server"

     

     

    onloaddocklayout="layout1_LoadDockLayout"

     

     

    onsavedocklayout="layout1_SaveDockLayout">

     

    <

     

    telerik:RadDockZone ID="RadDockZone5" Runat="server" Width="1316px" Height="180px" BorderWidth="0px" >

     

     

    <telerik:RadDock ID="ChromeTypeWebPart" Runat="server" Width="100px"

     

     

    AutoPostBack="true" OnDockPositionChanged="RadDock1_Command" >

     

     

    </telerik:RadDock>

     

     

    <telerik:RadDock ID="EditWebPart" Runat="server" Width="100px"

     

     

    AutoPostBack="true" OnDockPositionChanged="RadDock2_Command" >

     

    </

     

    telerik:RadDock>

     

     

    <telerik:RadDock ID="PagingWebPart" Runat="server" Width="100px"

     

     

    AutoPostBack="true" OnDockPositionChanged="RadDock3_Command" >

     

    </

     

    telerik:RadDock>

     

    </

     

    telerik:RadDockZone>

     

    </

     

    telerik:RadDockLayout>

     



    Code2:(user control code behaine)

     

    protected void Page_Init(object sender, EventArgs e)

     

    {

     

    Label LblPagingWebPart = new Label();

     

    LblPagingWebPart.ID =

    "LblPagingWebPart";

     

    LblPagingWebPart.Text =

    "PagingWebPart";

     

     

    Image imge1 = new Image();

     

    imge1.ID =

    "imgePagingWebPart";

     

    imge1.ImageUrl =

    "~/img1.JPG";

     

    PagingWebPart.ContentContainer.Controls.Add(imge1);

    PagingWebPart.ContentContainer.Controls.Add(LblPagingWebPart);

     

    // PagingWebPart.Undock();

     

     

    Label lbl2 = new Label();

     

    lbl2.ID =

    "LblChromeTypeWebpart";

     

    lbl2.Text =

    "ChromeTypeWebpart";

     

     

    Image imge2 = new Image();

     

    imge2.ID =

    "hello2";

     

    imge2.ImageUrl =

    "~/imag2.JPG";

     

    ChromeTypeWebPart.ContentContainer.Controls.Add(imge2);

    ChromeTypeWebPart.ContentContainer.Controls.Add(lbl2);

     

    // ChromeTypeWebPart.Undock();

     

     

    Label lbl3 = new Label();

     

    lbl3.ID =

    "LblEditWebPart";

     

    lbl3.Text =

    "EditWebPart";

     

     

    Image imge3 = new Image();

     

    imge3.ID =

    "hello3";

     

    imge3.ImageUrl =

    "~/imag2.JPG";

     

    EditWebPart.ContentContainer.Controls.Add(imge3);

    EditWebPart.ContentContainer.Controls.Add(lbl3);

     

    // EditWebPart.Undock();

     

     

    //for (int i = 0; i < CurrentDockStates.Count; i++)

     

     

    //{

     

     

    // RadDock dock = new RadDock();

     

     

    // dock.ID = string.Format("RadDock{0}", i);

     

     

    // dock.ApplyState(CurrentDockStates[i]);

     

     

    // layout1.Controls.Add(dock);

     

     

     

    //}

     

     

    }

     

    protected void RadDock3_Command(object sender, DockPositionChangedEventArgs e)

     

    {

     

    RadDock dock = (RadDock)sender;

     

     

    if (e.DockZoneID == String.Empty)

     

    dock.Text =

    String.Format("I used to be in {0} but now I am floating.", dock.DockZoneID);

     

     

    string strzone = e.DockZoneID;

     

     

    string Dockid = dock.ID;

     

    LoadDock(strzone, Dockid);

     

    // RadDockZone zone = (RadDockZone)dock.Parent;

     

     

    //RadDock raddo = new RadDock();

     

     

    //raddo.ID = Dockid;

     

     

     

    //Page p = Parent.Page;

     

     

    //RadDockZone zone = (RadDockZone)p.FindControl(strzone);

     

     

    //zone.Controls.Add(raddo);

     

     

     

    ////if (e.Command.Name == "MoveDown")

     

     

    //{

     

     

    // RadDock dock = (RadDock)sender;

     

     

    // if (dock.DockZoneID != string.Empty)

     

     

    // {

     

     

    // RadDockZone zone = (RadDockZone)dock.Parent;

     

     

     

    // int i = dock.Index;

     

     

    // if (i < zone.Docks.Count - 1)

     

     

    // {

     

     

    // RadDock nextDock = zone.Docks[i + 1];

     

     

    // zone.Docks[i] = nextDock;

     

     

    // zone.Docks[i + 1] = dock;

     

     

    // }

     

     

    // }

     

     

    //}

     

    }

     

     

    public void LoadDock(string strRadDockZone, string strRadDock)

     

    {

     

    RadDock dock = new RadDock();

     

     

    //dock.UniqueName = Guid.NewGuid().ToString().Replace('-', 'a');

     

    dock.ID =

    string.Format("RadDock{0}", dock.UniqueName);

     

     

    //string stractual= strRadDock..Length - 1;

     

    dock.Title = strRadDock;

    // "RadDock2" + i;

     

    dock.Text =

    string.Format("Added at ", DateTime.Now);

     

     

    // dock.Text = "RadDock2" + i + "<br>rad doc testing";

     

    dock.Tag = dock.Title;

    // "UserControls/HelloWorld.ascx";

     

    dock.DockMode =

    DockMode.Docked;

     

     

    //dock.AutoPostBack = true;

     

     

    // RadDockZone2.Controls.Add(dock);

     

     

    // LoadWidget(dock);

     

     

    // RadDock raddo = new RadDock();

     

     

    //raddo.ID = strRadDock;

     

     

    Page p = Parent.Page;

     

     

    RadDockZone zone = (RadDockZone)p.FindControl(strRadDockZone);

     

    zone.Controls.Add(dock);

     

    //LoadWidget(dock);

     

    }



     

    protected void RadDock2_Command(object sender, DockPositionChangedEventArgs e)

     

    {

     

    RadDock dock = (RadDock)sender;

     

     

    if (e.DockZoneID == String.Empty)

     

    dock.Text =

    String.Format("I used to be in {0} but now I am floating.", dock.DockZoneID);

     

     

    string strzone = e.DockZoneID;

     

     

    string Dockid = dock.ID;

     

     

    //RadDockZone zone = (RadDockZone)dock.Parent;

     

     

    LoadDock(strzone, Dockid);

    RadDockZone5.Docks.Clear();

     

     

    ////if (e.Command.Name == "MoveDown")

     

     

    //{

     

     

    // RadDock dock = (RadDock)sender;

     

     

    // if (dock.DockZoneID != string.Empty)

     

     

    // {

     

     

    // RadDockZone zone = (RadDockZone)dock.Parent;

     

     

     

    // int i = dock.Index;

     

     

    // if (i < zone.Docks.Count - 1)

     

     

    // {

     

     

    // RadDock nextDock = zone.Docks[i + 1];

     

     

    // zone.Docks[i] = nextDock;

     

     

    // zone.Docks[i + 1] = dock;

     

     

    // }

     

     

    // }

     

     

    //}

     

    }

     

    protected void RadDock1_Command(object sender, DockPositionChangedEventArgs e)

     

    {

     

    RadDock dock = (RadDock)sender;

     

     

    if (e.DockZoneID == String.Empty)

     

    dock.Text =

    String.Format("I used to be in {0} but now I am floating.", dock.DockZoneID);

     

     

    string strzone = e.DockZoneID;

     

     

    string Dockid = dock.ID;

     

    LoadDock(strzone, Dockid);

     

    // loaddock(strzone, Dockid);

     

     

    // RadDockZone zone = (RadDockZone)dock.Parent;

     

     

    //RadDock raddo = new RadDock();

     

     

    //raddo.ID = Dockid;

     

     

    ////zone.Controls.Add(raddo);

     

     

    //Page p = Parent.Page;

     

     

    //RadDockZone zone = (RadDockZone)p.FindControl(strzone);

     

     

    //zone.Controls.Add(raddo);

     

     

     

    ////if (e.Command.Name == "MoveDown")

     

     

    //{

     

     

    // RadDock dock = (RadDock)sender;

     

     

    // if (dock.DockZoneID != string.Empty)

     

     

    // {

     

     

    // RadDockZone zone = (RadDockZone)dock.Parent;

     

     

     

    // int i = dock.Index;

     

     

    // if (i < zone.Docks.Count - 1)

     

     

    // {

     

     

    // RadDock nextDock = zone.Docks[i + 1];

     

     

    // zone.Docks[i] = nextDock;

     

     

    // zone.Docks[i + 1] = dock;

     

     

    // }

     

     

    // }

     

     

    //}

     

    }



    Code3:(mainpage aspx)

    <%

    @ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="webapp._Default" %>

     

    <%

    @ Register src="WebUserControl.ascx" tagname="WebUserControl" tagprefix="uc1" %>

     

    <%

    @ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

     

    <!

     

    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

     

    <

     

    html xmlns="http://www.w3.org/1999/xhtml" >

     

    <

     

    head runat="server">

     

     

    <title></title>

     

     

    <style type="text/css">

     

     

    .style1

     

    {

     

    width: 100%;

     

    }

     

    </style>

     

    </

     

    head>

     

    <

     

    body>

     

     

    <form id="form1" runat="server">

     

     

    <div>

     

     

     

    <script type="text/javascript">

     

     

     

    function openRadWindow() {

     

     

    var rwManager = $find("<%= RadWindowManager1.ClientID %>");

     

     

    var rwindow = rwManager.Open("", "RadWindow1");

     

     

    //rwindow.center();

     

     

    return false;

     

    }

     

    </script>

     

     

    <asp:ScriptManager ID="ScriptManager1" runat="server">

     

     

    </asp:ScriptManager>

     

    <%

    --<telerik:RadScriptManager ID="RadScriptManager1" runat="server">

     

    </telerik:RadScriptManager>--

     

    %>

     

     

     

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">

     

     

    <ContentTemplate>

     

     

    <table class="style1">

     

     

    <tr><td><input type="button" value="Add Stuff" onclick="openRadWindow();" /> </td></tr>

     

     

    <tr>

     

     

    <td colspan="2" valign="top" style="height: 200px">

     

     

    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">

     

     

    <Windows>

     

     

    <telerik:RadWindow ID="RadWindow1" runat="server"

     

     

    Top="0" Left="0" Width="1336px" Height="200px" ShowContentDuringLoad="false"

     

     

    Modal="false" VisibleTitlebar="false" VisibleStatusbar="false" BorderWidth="0px">

     

     

    <ContentTemplate>

     

     

    <uc1:WebUserControl ID="WebUserControl1" runat="server" />

     

     

    </ContentTemplate>

     

     

    </telerik:RadWindow>

     

     

    </Windows>

     

     

    </telerik:RadWindowManager>

     

     

     

    </td>

     

     

    <td>

     

     

    &nbsp;</td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td>

     

     

     

    <telerik:RadDockLayout ID="RadDockLayout1" Runat="server" OnLoadDockLayout="RadDockLayout1_LoadDockLayout" OnSaveDockLayout="RadDockLayout1_SaveDockLayout">

     

     

    <telerik:RadDockZone ID="RadDockZone1" Runat="server">

     

     

    </telerik:RadDockZone>

     

     

    </telerik:RadDockLayout>

     

     

    </td>

     

     

    <td style="width: 50px;">

     

     

    <asp:Button ID="BtnAddFlag" runat="server" Text="Add Flag" />

     

    <%

    -- <uc1:WebUserControl ID="WebUserControl1" runat="server" />--%>

     

     

    </td>

     

     

    </tr>

     

     

    </table>

     

     

    </ContentTemplate>

     

     

    </asp:UpdatePanel>

     

     

     

    </div>

     

     

    </form>

     

    </

     

    body>

     

    </

     

    html>

     





  • Pero Pero admin's avatar

    Posted on Nov 11, 2010 (permalink)

    Hi Sridharreddy,

    We have a sample project that I believe will help you achieve your specific scenario. It shows how to create a RadDock object on the client by initially dragging a fixed dock inside a zone that acts as a toolbox. Please note that there is no server side interaction - the docks are created on the client only. You should modify it to create the docks and their user controls on the server, with the same settings and properties.

    The full source code of the application is attached to the thread.

    All the best,
    Pero
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
    Attached files

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Docking > Restore the Existing Docks after draging from usercontrol in Radwindow to other page dock zone