6 Answers, 1 is accepted

You can use the SaveDockLayout event to achieve your requirement. The SaveDockLayout event occurs when it is appropriate for the application to save the state of all its RadDock controls to a storage medium such as the Session, a cookie, or a database. This event should be used to store the state of RadDock controls in any of the following situations:
-
The StoreLayoutInViewState property of the RadDockLayout control is False.
-
You want to save the state of RadDock controls when the user leaves the Web page and restore it when the user returns to the Web page.
- The application dynamically creates RadDock controls at runtime.
Typically a SaveDockLayout event handler uses the RadDockLayout control's GetRegisteredDocksState method, which returns a list of DockState objects that represent the state and position of the each RadDock control managed by the RadDockLayout. Please have a look into the following code.
C#:
protected
void
RadDockLayout1_SaveDockLayout(
object
sender, DockLayoutEventArgs e)
{
HttpCookie dockState = Page.Response.Cookies.Get(
"MyApplicationDockStates"
);
if
(dockState ==
null
)
{
dockState =
new
HttpCookie(
"MyApplicationDockStates"
);
Page.Response.Cookies.Add(dockState);
}
List<DockState> stateList = ((RadDockLayout)sender).GetRegisteredDocksState();
StringBuilder serializedList =
new
StringBuilder();
for
(
int
i = 0; i < stateList.Count; i++)
{
serializedList.Append(stateList[i].ToString());
serializedList.Append(
"|"
);
}
dockState.Expires = DateTime.Today.AddMonths(1);
dockState.Value = serializedList.ToString();
}
Thanks,
Shinu.
You can also try the new Built-In Dock State Persistence. It allows you to automatically store the dock state in a cookie by setting the property EnableStoreLayout of RadDockLayout to true and the property LayoutStorageType to Cookies.
All the best,
Slav
the Telerik team

I tried Built-In Dock State Persistence by setting the property EnableStoreLayoutPersistence of RadDockLayout to true and the property LayoutPersisitenceRepositoryType to Custom to store the dock state in a database by creating a class that implements the interface IStateStorageProvider and setting an instance of this class to the property StorageProvider of RadDockLayout.
The state is being saved the very first time I open the page. I change the state of the docks by moving them around and minimizing and closing some, closing the page and then opening again is not storing the changed state.
Is there any event that I need to raise to save the dock state? Am I missing something here...
Please let me know.
Thanks,
NK
Please ensure that the custom storage provider is set on Page_Init as shown in the online demo you linked. Also, I would suggest checking if there is a problem with writing and reading the state from your database. Examine if there is any data in the row of the database table, in which the state is stored.
If the problem persists, you can run the demo locally (it is located in [RadControls for ASP.NET AJAX installation path]\Live Demos\Dock\Examples\BuiltInDockStatePersistence) and use it as a reference for configuring the built-in dock state persistence on your end.
Regards,
Slav
the Telerik team

Hi Slav,
Thank you very much for the response. So, after changing the state of the docks by moving them around, minimizing or closing them, do I need a button like "Save State" to save the state.
In the example located in [RadControls for ASP.NET AJAX installation path]\Live Demos\Dock\Examples\BuiltInDockStatePersistence) also, the state is being saved only after clicking the button “Save State”.
Is there a way this can be achieved without using a button? Please let me know.
Thanks for all your help,
NKThe button in the mentioned live demo is used to trigger a postback - you can achieve the required functionality without external button by setting RadDock's AutoPostBack and CommandsAutoPostBack to True to configure the control to trigger a postback itself.
Greetings,
Dobromir
the Telerik team