RadDock server side DockPositionChanged does not fire when dropping control in the same position

4 posts, 0 answers
  1. Hung Leong
    Hung Leong avatar
    2 posts
    Member since:
    Apr 2015

    Posted 29 Apr 2015 Link to this post

    I dynamically created raddocks on the server side.

    dock.DockPositionChanged += new DockPositionChangedEventHandler(dock_DockPositionChanged);

    So I used this line of code to add event handler, however it only gets fired when the control is dropped to another position. It doesn't get fired if I dropped it to the same position.

    How do I make it gets fired even if I drop it to the same position. Thanks.

  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1492 posts

    Posted 04 May 2015 Link to this post

    Hi Hung,

    The server-side OnDockPositionChanged event is fired when one of the following changes with the dock are done:
    • A move from one RadDockZone control to another.

    • A move from a RadDockZone control to a floating position.

    • A move from a floating position to a RadDockZone control.

    • A change of index within a RadDockZone control.

    More information on the matter is available here - http://docs.telerik.com/devtools/aspnet-ajax/controls/dock/server-side-programming/events/dockpositionchanged

    If you want to call a server-side event when a dock is positioned to the same position you can handle the client-side OnClientDockPositionChanged event where you can trigger an AJAX request and execute the server-side logic.​

    Regards,
    Danail Vasilev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hung Leong
    Hung Leong avatar
    2 posts
    Member since:
    Apr 2015

    Posted 04 May 2015 Link to this post

    What if I could only bind DockPositionChanged event handler on the server as raddocks are created dynamically on the server side. How to achieve this?
  5. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1492 posts

    Posted 07 May 2015 Link to this post

    Hi Hung,

    You can attach to the DockPositionChanged event for a dynamically created dock like that:

    ASPX:
    <telerik:RadDockZone ID="RadDockZone1" runat="server">
        <telerik:RadDock ID="RadDock1" runat="server">
            <ContentTemplate>
                dock 1
            </ContentTemplate>
        </telerik:RadDock>
    </telerik:RadDockZone>
    <asp:Label ID="Label1" Text="" runat="server" />
    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadDock rd1 = new RadDock();
        rd1.AutoPostBack = true;
        rd1.ID = "dock2";
        rd1.DockPositionChanged += new DockPositionChangedEventHandler(RadDock1_DockPositionChanged);
        RadDockZone1.Controls.Add(rd1);
     
    }
    protected void RadDock1_DockPositionChanged(object sender, DockPositionChangedEventArgs e)
    {
        Label1.Text = DateTime.Now.ToString();
    }

    Note that this is a server-side event, so in order for it to be fired you should set the AutoPostBack property of the dock to true.

    Regards,
    Danail Vasilev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top