DockPositionChanged event handler for programmatically created RadDock

4 posts, 1 answers
  1. Richard M
    Richard M avatar
    76 posts
    Member since:
    Mar 2010

    Posted 14 Dec 2010 Link to this post

    How do I create and trigger an Event Handler for a programatically created RadDock when I change it's position inside of a RadDockZone?
  2. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 15 Dec 2010 Link to this post

    Hi Richard,

    To achieve the desired scenario you should handle the RadDock's DockPositionChanged server-side event, and set its AutoPostBack property to true. Please note that, for the event to be fired you need to attach the handler on every post-back in the Page.Init event.
    For your convenience I have created a sample project that dynamically creates a dock and attaches the DockPositionedChanged event. Here is the full source code:
    .aspx
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="RadScriptManager1" runat="server">
        </asp:ScriptManager>
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server">
            <telerik:RadDockZone ID="RadDockZone1" runat="server" MinHeight="300px" Width="300px">
                <telerik:RadDock ID="RadDock1" runat="server" Title="RadDock-Title" Width="300px"
                    Height="300px">
                    <ContentTemplate>
                        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eu leo quis felis eleifend
                        congue id ac nulla. Suspendisse in sapien eu tortor aliquam luctus. Suspendisse
                        pretium, nulla sit amet porttitor lobortis, ante sapien blandit ante, et tempor
                        magna eros nec sapien. In hac habitasse platea dictumst. Nullam a quam lorem, eu
                        vestibulum turpis. Praesent a neque et diam tincidunt suscipit ut semper massa.
                        Vivamus posuere, mi eu consectetur consequat, libero risus accumsan erat, ut facilisis
                        dolor justo a enim. Donec suscipit tincidunt lorem, sed aliquam velit pulvinar euismod.
                        Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus
                        mus.
                    </ContentTemplate>
                </telerik:RadDock>
            </telerik:RadDockZone>
        </telerik:RadDockLayout>
        </form>
    </body>
    </html>

    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
     
    using System.Data;
    using System.Configuration;
    using System.Web.Security;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Telerik.Web.UI;
    using System.Drawing;
     
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            RadDock dock = new RadDock();
            dock.ID = "RadDock2";
            dock.AutoPostBack = true;
            dock.DockPositionChanged += new DockPositionChangedEventHandler(dock_DockPositionChanged);
     
            RadDockLayout1.Controls.Add(dock);
            dock.DockZoneID = RadDockZone1.ClientID;
        }
     
        protected void dock_DockPositionChanged(object sender, DockPositionChangedEventArgs e)
        {
            RadDock dock = sender as RadDock;
            dock.Text = "The RadDock was moved at: " + DateTime.Now.ToString();
        }
    }

    Greetings,
    Pero
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Richard M
    Richard M avatar
    76 posts
    Member since:
    Mar 2010

    Posted 15 Dec 2010 Link to this post

    That's exactly what I needed.  Thank you very much.
  5. Brian Lanham
    Brian Lanham avatar
    3 posts
    Member since:
    Apr 2010

    Posted 09 Feb 2011 Link to this post

    Thank you!  Reattaching in Page_Init is what I was missing!
Back to Top