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

Saving/Postback Dynamic Controls within Dynamic Docks - Possible? (HELP!)

3 Answers 130 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Chris Mitchell
Top achievements
Rank 1
Chris Mitchell asked on 18 Nov 2009, 03:05 PM
Hi,

Thanks in advance for any help. This is going to basically decide if I can use the Telerik controls for a big project I am working on (and thus, whether or not we buy licenses).. So any help is greatly appreciated!

What I want to do is dynamically add docks to a dock zone, and then add child controls into these docks based upon user selection. I have followed along with the example @ http://www.telerik.com/help/aspnet-ajax/dock_dockwidgets.html and I have this basically working. However, the problem that I am running into is that I cannot seem to get those child components to persist. Since all of the dock actions do an ajax postback, I end up losing all but my last dock's child controls.

Essentially I want to be able to do these steps:
1. Click a button/linkbutton to dynamically create a dock within a dockzone.
2. Create child controls within that new dock, type depending upon which button was clicked,
3. Continue steps 1-2 until the user has added all of the docks they need (these correspond to fields for a database table).
4. The user should be able to go through the docks and set values into the various child controls and then be able to submit it to the server where I can then access all the various controls and process it from there.

It is the child control persistence that has me stumped.

I hope my explanation makes sense; I'm new to the Telerik suite of tools and still finding my way around. Any help or example code (even a very simple example) would be massively appreciated. I might even send you a cookie! :)

Thanks in advance!

3 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 19 Nov 2009, 09:03 AM
Hi Chris,

I think that the my portal example will give you an idea how to implement your specific scenario. You can easily modify it to save the state of the RadDocks in a DataBase.

If you want to dynamically add controls inside the RadDock you should add them to the RadDock.ContentContainer and they will appear in the dock's content. Please note that every control that is dynamically added to the RadDock needs to be recreated in the Page_Init method (before the ViewState is loaded and at the same time when the RadDock control is recreated from the state).

The state of the docks' child controls should be saved in the DockSaveLayout server-side event when the DockState is saved in a DB (or the Session). To find the controls that are inside the dock content container use RadDock.ContentContainer.FindControl(ControlID).

I hope my suggestions were helpful. If you have other questions, please do contact us. 

Sincerely yours,
Pero
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Chris Mitchell
Top achievements
Rank 1
answered on 19 Nov 2009, 11:08 PM
"Please note that every control that is dynamically added to the RadDock needs to be recreated in the Page_Init method (before the ViewState is loaded and at the same time when the RadDock control is recreated from the state).

The state of the docks' child controls should be saved in the DockSaveLayout server-side event when the DockState is saved in a DB (or the Session)."

This is the part that is forming a bit of a stumbling block for me. I see how you do it in your example where you make a user control for each 'type' of dock that would be added and then you track which ones are there and load them in.. But if I wanted to do this with simple controls (such as labels, text areas, etc), I am at a loss for how I save their status as being in a dock.

Any examples available of adding and persisting a child control within a dock that is NOT simply loading in a user control?

Forgive me if I am being dense.m
0
Pero
Telerik team
answered on 25 Nov 2009, 11:12 AM
Hello Chris,

Well one way of doing this is using the dock.UniqueName and dock.Tag properties. For example a certain label in a dock will have an ID composed of "Label_" + dock.UniqueName and the dock.Tag can have some other flag carrying some information about which controls can be added to the dock. This way you know which Label (or any control) is placed in which dock.

At the moment we do not have an example or online demo that implements this specific scenario.

Greetings,
Pero
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Dock
Asked by
Chris Mitchell
Top achievements
Rank 1
Answers by
Pero
Telerik team
Chris Mitchell
Top achievements
Rank 1
Share this question
or