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

Dock - DockPositionChanged event fires after Init

2 Answers 29 Views
Dock
This is a migrated thread and some comments may be shown as answers.
AnneArents
Top achievements
Rank 1
AnneArents asked on 06 Nov 2012, 12:54 PM
Hi,

I'm using dynamically created RadDockZones and RadDocks to represent data.
Everything is dynamically created during the Page_Init event.
Whenever a Dock is dragged to a different DockZone, I want to save its new position (DockZone) in the database.
I'm using the DockPositionChanged event for this.

However, when a Dock is dragged to another DockZone, triggering the DockPositionChanged event, the Page_Init event is fired BEFORE the DockPositionChanged event.
This means that while the new position (DockZone) of the Dock is correctly saved in the database, it's not shown until a refresh of the page.

Is there a way to deal with this without having to go throught the trouble of loading/saving the state?

Cheers,
CJ

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Nov 2012, 05:06 AM
Hi,

Try the following code to achieve your scenario.

C#:
protected void RadDockZone1_Init(object sender, EventArgs e)
{
 if (!IsPostBack)
 {
   // Your Code
 }
}

Hope this helps.

Thanks,
Princy.
0
Slav
Telerik team
answered on 09 Nov 2012, 11:22 AM
Hello,

The recommended approach for dynamically creating RadDocks and persisting their state is described in this help article. If you implement it, the RadDockLayout will take care of displaying the docks in the correct position when they are moved and a postback occurs.

If you still want to use your custom approach for saving/loading the state, I would suggest utilizing the DockPositionChanged event in order to get the dock zone, in which the dock is currently placed, and dock it in this zone through the Dock method as shown below:
public void RadDock1_DockPositionChanged(object sender, DockPositionChangedEventArgs e)
{
    string currentDockZone = e.DockZoneID;
    RadDock1.Dock(currentDockZone);
}


Greetings,
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.
Tags
Dock
Asked by
AnneArents
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Slav
Telerik team
Share this question
or