Problem with RadDock using Master page

14 posts, 0 answers
  1. Michael Harris
    Michael Harris avatar
    3 posts
    Member since:
    Dec 2008

    Posted 27 Aug 2009 Link to this post

    Hi,

    I am trying to figure out why I am having a problem with RadDock when I use a master page. If I split the same functionality up using a master page then I seem to have problems when I dynamically create a RadDock. I think it might have something to do with the fact that the first time a RadDock is created it is in a postback click handler, subsequent creation of the RadDock happen in the init handler. However, I only see this problem when I use a master page. I do not see the same problem when all code is within a single page.

    The problem I am having is that I create a RadDock in a click handler and then I attempt to move the RadDock to a different zone, the RadDock 'snaps' back to the zone it was created in, if I then try to move the RadDock I am successful.

    I have included a DockNoMaster.aspx/cs which works as I expect. I can click on Add Module and a RadDock is created in the middle zone. I can move the RadDock to the right or left zone and click Postback and the RadDock 'remebers' its position.

    --DockNoMaster.aspx

     

     

    <telerik:RadScriptManager ID="ScriptManager1" runat="server" />

     

     

     

     

     

     

    <telerik:RadDockLayout runat="server" ID="RadDockLayout1" EnableEmbeddedSkins="false" >

     

     

     

     

     

     

    <table>

     

     

     

     

     

    <tr>

     

     

     

     

     

    <td bgcolor="#99ffcc">

     

     

     

     

     

    <telerik:RadDockZone runat="server" ID="leftZone" Width="200" MinHeight="200" Orientation="vertical" Style="border: 0px;" />

     

     

     

     

     

    </td>

     

     

     

     

     

    <td bgcolor="#99ffcc">

     

     

     

     

     

    <asp:Button runat="server" ID="btnAddModule" OnClick="btnAddModule_Click" Text="Add Module" />

     

     

     

     

     

    &nbsp;<asp:Button runat="server" ID="btnPostback" OnClick="btnPostback_Click" Text="Postback" />

     

     

     

     

     

    <br /><br />

     

     

     

     

     

    <telerik:RadDockZone runat="server" ID="middleZone" Width="200" MinHeight="200" Orientation="vertical" Style="border: 0px;" />

     

     

     

     

     

    </td>

     

     

     

     

     

    <td bgcolor="#99ffcc">

     

     

     

     

     

    <telerik:RadDockZone runat="server" ID="rightZone" Width="200" MinHeight="200" Orientation="vertical" Style="border: 0px;" />

     

     

     

     

     

    </td>

     

     

     

     

     

    </tr>

     

     

     

     

     

    </table>

     

     

     

     

     

     

    </telerik:RadDockLayout>

     

     

     

    --DockNoMaster.cs

     

    public

     

    partial class Test_Templates_DockNoMaster : System.Web.UI.Page

     

     

     

     

     

    {

     

    protected void Page_Load(object sender, System.EventArgs e)

     

    {

     

    if (!IsPostBack)

     

    {

    }

    }

     

    private List<DockState> CurrentDockStates

     

    {

     

    get

     

     

     

     

     

    {

     

    List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesDynamicDocks"];

     

     

    if (Object.Equals(_currentDockStates, null))

     

    {

    _currentDockStates =

    new List<DockState>();

     

    Session[

    "CurrentDockStatesDynamicDocks"] = _currentDockStates;

     

    }

     

    return _currentDockStates;

     

    }

     

    set

     

     

     

     

     

    {

    Session[

    "CurrentDockStatesDynamicDocks"] = value;

     

    }

    }

     

    private RadDock CreateRadDockFromState(DockState state)

     

    {

     

    RadDock dock = new RadDock();

     

    dock.DockMode =

    DockMode.Docked;

     

    dock.ID =

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

     

    dock.ApplyState(state);

    dock.Commands.Add(

    new DockCloseCommand());

     

    dock.Commands.Add(

    new DockExpandCollapseCommand());

     

    dock.AutoPostBack =

    true;

     

    dock.CommandsAutoPostBack =

    true;

     

     

    return dock;

     

    }

     

    void dock_DockPositionChanged(object sender, DockPositionChangedEventArgs e)

     

    {

    }

     

    private RadDock CreateRadDock()

     

    {

     

    int docksCount = CurrentDockStates.Count;

     

     

    RadDock dock = new RadDock();

     

    dock.DockMode =

    DockMode.Docked;

     

    dock.UniqueName =

    Guid.NewGuid().ToString();

     

    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());

     

    dock.AutoPostBack =

    true;

     

    dock.CommandsAutoPostBack =

    true;

     

     

    return dock;

     

    }

     

    protected void Page_Init(object sender, EventArgs e)

     

    {

     

    RadDockLayout dockLayout = RadDockLayout1;

     

    dockLayout.LoadDockLayout +=

    new DockLayoutEventHandler(dockLayout_LoadDockLayout);

     

    dockLayout.SaveDockLayout +=

    new DockLayoutEventHandler(dockLayout_SaveDockLayout);

     

     

     

     

     

     

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

     

    {

     

    RadDock dock = CreateRadDockFromState(CurrentDockStates[i]);

     

    dockLayout.Controls.Add(dock);

    }

    }

     

    protected void dockLayout_LoadDockLayout(object sender, DockLayoutEventArgs e)

     

    {

     

    foreach (DockState state in CurrentDockStates)

     

    {

    e.Positions[state.UniqueName] = state.DockZoneID;

    e.Indices[state.UniqueName] = state.Index;

    }

    }

     

    protected void dockLayout_SaveDockLayout(object sender, DockLayoutEventArgs e)

     

    {

     

    RadDockLayout dockLayout = RadDockLayout1;

     

    CurrentDockStates = dockLayout.GetRegisteredDocksState();

    }

     

    protected void btnAddModule_Click(object sender, EventArgs e)

     

    {

     

    RadDockLayout dockLayout = RadDockLayout1;

     

     

    RadDock dock = CreateRadDock();

     

    middleZone.Controls.Add(dock);

    }

     

    protected void btnPostback_Click(object sender, EventArgs e)

     

    {

    }

    }

     

    I have also included DockWithMaster.aspx/cs and DockMaster.master/cs which does not work as I expect. If I click Add Module then a RadDock is created in the middle zone. However, if I drag the RadDock to the left or right zone it immediately goes back to the middle zone. The second time I move the RadDock to the left or right zone, it will remember its position.

    In the master sample the RadDockLayout and the left and right RadDockZone are in the DockMaster.master file. The middle RadDockZone and the add and postback buttons are in the DockWithMaster.aspx file. The saving and loading of dock state is handled in the content .aspx file, not the master.

    -- DockMaster.master

     

     

    <telerik:RadScriptManager ID="ScriptManager1" runat="server" />

     

     

     

    <telerik:RadDockLayout runat="server" ID="RadDockLayout1" EnableEmbeddedSkins="false" >

     

     

     

    <table>

     

     

    <tr>

     

     

    <td bgcolor="#99ffcc">

     

     

    <telerik:RadDockZone runat="server" ID="leftZone" Width="200" MinHeight="200" Orientation="vertical" Style="border: 0px;" />

     

     

    </td>

     

     

    <td bgcolor="#99ffcc">

     

     

    <asp:ContentPlaceHolder id="middleContent" runat="server" />

     

     

    </td>

     

     

    <td bgcolor="#99ffcc">

     

     

    <telerik:RadDockZone runat="server" ID="rightZone" Width="200" MinHeight="200" Orientation="vertical" Style="border: 0px;" />

     

     

    </td>

     

     

    </tr>

     

     

    </table>

     

     

     

    </telerik:RadDockLayout>

    -- DockMaster.cs does not have anything in it

    -- DockWithMaster.aspx

     

     

     

    <

     

    asp:Content ID="Content1" ContentPlaceHolderID="middleContent" runat="server">

     

     

    <asp:Button runat="server" ID="btnAddModule" OnClick="btnAddModule_Click" Text="Add Module" />

     

     

    &nbsp;<asp:Button runat="server" ID="btnPostback" OnClick="btnPostback_Click" Text="Postback" />

     

     

    <br /><br />

     

     

    <telerik:RadDockZone runat="server" ID="middleZone" Width="200" MinHeight="200" Orientation="vertical" Style="border: 0px;" />

     

    </

     

    asp:Content>

     

     

     

    -- DockWithMaster.cs

     

    public

     

    partial class Test_Templates_DockWithMaster : System.Web.UI.Page

     

    {

     

    protected void Page_Load(object sender, System.EventArgs e)

     

    {

     

    if (!IsPostBack)

     

    {

    }

    }

     

    private List<DockState> CurrentDockStates

     

    {

     

    get

     

    {

     

    List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesDynamicDocks"];

     

     

    if (Object.Equals(_currentDockStates, null))

     

    {

    _currentDockStates =

    new List<DockState>();

     

    Session[

    "CurrentDockStatesDynamicDocks"] = _currentDockStates;

     

    }

     

    return _currentDockStates;

     

    }

     

    set

     

    {

    Session[

    "CurrentDockStatesDynamicDocks"] = value;

     

    }

    }

     

    private RadDock CreateRadDockFromState(DockState state)

     

    {

     

    RadDock dock = new RadDock();

     

    dock.DockMode =

    DockMode.Docked;

     

    dock.ID =

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

     

    dock.ApplyState(state);

    dock.Commands.Add(

    new DockCloseCommand());

     

    dock.Commands.Add(

    new DockExpandCollapseCommand());

     

    dock.AutoPostBack =

    true;

     

    dock.CommandsAutoPostBack =

    true;

     

     

    return dock;

     

    }

     

    void dock_DockPositionChanged(object sender, DockPositionChangedEventArgs e)

     

    {

    }

     

    private RadDock CreateRadDock()

     

    {

     

    int docksCount = CurrentDockStates.Count;

     

     

    RadDock dock = new RadDock();

     

    dock.DockMode =

    DockMode.Docked;

     

    dock.UniqueName =

    Guid.NewGuid().ToString();

     

    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());

     

    dock.AutoPostBack =

    true;

     

    dock.CommandsAutoPostBack =

    true;

     

     

    return dock;

     

    }

     

    protected void Page_Init(object sender, EventArgs e)

     

    {

     

    RadDockLayout dockLayout = (RadDockLayout)this.Master.FindControl(middleZone.LayoutID);

     

    dockLayout.LoadDockLayout +=

    new DockLayoutEventHandler(dockLayout_LoadDockLayout);

     

    dockLayout.SaveDockLayout +=

    new DockLayoutEventHandler(dockLayout_SaveDockLayout);

     

     

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

     

    {

     

    RadDock dock = CreateRadDockFromState(CurrentDockStates[i]);

     

    dockLayout.Controls.Add(dock);

    }

    }

     

    protected void dockLayout_LoadDockLayout(object sender, DockLayoutEventArgs e)

     

    {

     

     

    foreach (DockState state in CurrentDockStates)

     

    {

    e.Positions[state.UniqueName] = state.DockZoneID;

    e.Indices[state.UniqueName] = state.Index;

    }

    }

     

    protected void dockLayout_SaveDockLayout(object sender, DockLayoutEventArgs e)

     

    {

     

    RadDockLayout dockLayout = (RadDockLayout)this.Master.FindControl(middleZone.LayoutID);

     

    CurrentDockStates = dockLayout.GetRegisteredDocksState();

    }

     

    protected void btnAddModule_Click(object sender, EventArgs e)

     

    {

     

    RadDockLayout dockLayout = (RadDockLayout)this.Master.FindControl(middleZone.LayoutID);

     

     

    RadDock dock = CreateRadDock();

     

    middleZone.Controls.Add(dock);

    }

     

    protected void btnPostback_Click(object sender, EventArgs e)

     

    {

    }

    }

  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 31 Aug 2009 Link to this post

    Hi Michael,

    We have responded to your question in the corresponding support ticket. Please find the answer there.


    Regards,
    Pero
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sarin Rajendran
    Sarin Rajendran avatar
    3 posts
    Member since:
    Sep 2009

    Posted 06 Oct 2009 Link to this post

    Hi,

    I have a similar/related problem using docking controls spanning Master and content pages. I tried to attach a sample project which illustrates the problem, but the page prevents me from uploading zip files.

    In my case, the forbiddenZones property doesn't work when RadDockZones span Master and Content pages. In Default.aspx, I have a RadDockLayout with 4 RadDockZones. 2 of the RadDockZones are set as forbidden Zones for Docks in the other 2 RadDockZones. No issues - things work as expected.

    The same layout is split into Master and Content pages. The RadDockLayout and 2 of the RadDockZones are now in the Dock.master while the other 2 RadDockZones are moved to the DockContent.aspx page. Identical code is used to set forbidden Zones for Docks as in Default.aspx. However, this does not apply - docks can be docked to any zones.

    Thanks,
    Sarin.
  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 08 Oct 2009 Link to this post

    Hello Sarin,

    I created a similar project based on the information that you have provided and everything seems to be working correctly. The ForbiddenZones property of the RadDock is respected, and the dock cannot be docked in the zones that are "forbidden". Please find the project attached to the thread.


    Sincerely yours,
    Pero
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Sarin Rajendran
    Sarin Rajendran avatar
    3 posts
    Member since:
    Sep 2009

    Posted 13 Oct 2009 Link to this post

    Thanks Pero,
    To clarify, the ForbiddenZones array expects the IDs of RadDockZones and not their ClientIDs.
  7. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 14 Oct 2009 Link to this post

    Hi Sarin,

    That is correct. You need to use the IDs of the RadDockZones to specify which zones should be forbidden for certain RadDock, and not their ClientIDs.


    Greetings,
    Pero
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Måns
    Måns avatar
    6 posts
    Member since:
    Sep 2008

    Posted 08 Sep 2011 Link to this post

    Hi

    I also have the same problem as described in the first post..

    What was the solution?

    Regards
  9. Måns
    Måns avatar
    6 posts
    Member since:
    Sep 2008

    Posted 08 Sep 2011 Link to this post

    What was the solution?
  10. Måns
    Måns avatar
    6 posts
    Member since:
    Sep 2008

    Posted 13 Sep 2011 Link to this post

    For anyone else interests there is no solution. RadDock is not 100% MasterPage compatible.
  11. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 13 Sep 2011 Link to this post

    Hello Måns,

    I have already answered your question in the according support ticket. Nevertheless, I will post the suggested solution here as well, so that the community can benefit from it.

    Please note that in the code sample, presented in the forum thread, the RadDockLayout and two of the RadDockZones are placed on the master page, and the RadDockZone, in which the docks are created dynamically, is placed on the content page. Such usage of the RadDocks is incorrect and will lead to unexpected behavior, because the RadDockZone, in which the docks are added dynamically, is not placed directly into the RadDockLayout. As a result the states of the current docks will not be saved correctly.

    If this is the case, I would recommend either placing the RadDockLayout with the RadDockZones on the master page or on the content page, but not on both pages. Doing so will ensure the correct management of the RadDocks' states.

    You can find attached a sample project, implementing the solution above.

    When using our support tickets in the future, please send only one ticket on a particular problem. As you will most probably agree, this way it will be much easier to keep track of the communication and the problems will be resolved faster. My suggestion is to continue our conversation in your original support ticket.

    Greetings,
    Slav
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  12. Måns
    Måns avatar
    6 posts
    Member since:
    Sep 2008

    Posted 14 Sep 2011 Link to this post

    I posted in the forums first because my support had expired, but when no one answered I extended the support licence and opened up a ticket.

    Anyway, unfortunately the requirements are dynamically added raddocks in both masterpage (footer, header) and in the content page (content) which seems unsolveable.

  13. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 16 Sep 2011 Link to this post

    Hello Måns,

    Indeed, the the RadDockZones with the dynamically added RadDocks should be placed directly into the RadDockLayout, if the layout resides on the Master Page.

    There is still an option to implement separate RadDock functionality for the Master Page and the Content Page of your project.

    Best wishes,
    Slav
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
  14. Måns
    Måns avatar
    6 posts
    Member since:
    Sep 2008

    Posted 19 Sep 2011 Link to this post

    Hello

    Ok. Anyway it seems I got things working now by adding [ViewStateModeById] on our derived custom dock classes, and also adding dynamic docks to docklayout control instead of radzone control.


    Cheers
  15. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 21 Sep 2011 Link to this post

    Hi Måns,

    We are glad to hear that you have managed to resolve the encountered problem!

    Indeed, it is recommended to add a dynamically created RadDocks in the RadDockLayout and then to use its method Dock in order to dock it in the according RadDockZone. This way you will ensure that ViewState issues on subsequent postback, concerning the RadDocks, are avoided.
    RadDockLayout1.Controls.Add(RadDock1);
    RadDock1.Dock(RadDockZone1);


    Best wishes,
    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017