Bug with DockPositionChanged Not Firing

2 posts, 0 answers
  1. Zhi
    Zhi avatar
    9 posts
    Member since:
    Sep 2010

    Posted 23 Aug 2011 Link to this post

    Hi there,

    I'm using version 2011.1.413.40.

    The test_DockPositionChanged event here fires if solely defined in the aspx.

        <asp:ScriptManager ID="ScriptManager1" runat="server">
                <telerik:RadDockZone ID="RadDockZoneToolBox" runat="server" Height="200px" Width="100%"  BorderStyle="Dotted" BorderColor="Red" FitDocks="false"  Orientation="Horizontal">
                <telerik:RadDock ID="test" runat="server" AutoPostBack="true" OnDockPositionChanged="test_DockPositionChanged"></telerik:RadDock>

    However if it is defined programmatically in code it does not fire at all.

            protected void Page_Load(object sender, EventArgs e)
                test.DockPositionChanged += new DockPositionChangedEventHandler(test_DockPositionChanged);

            void test_DockPositionChanged(object sender, DockPositionChangedEventArgs e)
                // Does not fire

    Is this a bug or am I attaching the event at the wrong stage in the control creation life cycle?
  2. Slav
    Slav avatar
    1351 posts

    Posted 25 Aug 2011 Link to this post

    Hi Zhi,

    Truly, the event handler for the OnDockPositionChanged event is attached too late in the page lifecycle. If you want to create RadDock controls dynamically, which includes attaching the event handlers, you should do it in the Init event of the page, in order to allow the RadDockLayout to automatically manage their positions.

    You can check this help article, concerning the dynamic creation of a RadDock and where in the page lifecycle should the control be added.

    So in order to correctly define the event handler programmatically, you should specify it on Page.Init as shown on the example below:
    protected override void OnInit(EventArgs e)
        test.DockPositionChanged += new DockPositionChangedEventHandler(test_DockPositionChanged);

    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. DevCraft R3 2016 release webinar banner
Back to Top