This is a migrated thread and some comments may be shown as answers.

Bug with DockPositionChanged Not Firing

1 Answer 110 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Zhi
Top achievements
Rank 1
Zhi asked on 23 Aug 2011, 07:29 AM
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">
    </asp:ScriptManager>
            <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>
                </telerik:RadDockZone>
        </telerik:RadDockLayout>

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?

1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 25 Aug 2011, 12:13 PM
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)
{
    base.OnInit(e);
    test.DockPositionChanged += new DockPositionChangedEventHandler(test_DockPositionChanged);
}

Regards,
Slav
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 >>

Tags
Dock
Asked by
Zhi
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or