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

Passing Data To a UserControl in a dock object

4 Answers 150 Views
Dock
This is a migrated thread and some comments may be shown as answers.
ThePope
Top achievements
Rank 1
ThePope asked on 03 Sep 2008, 11:04 PM
Hello,
    I have a page that has several dockable user controls on it, each one showing different information about a common object.
 
I am progromatically defining the control on the page in the codebehind as so:

Dim newdock As RadDock = CreateRadDock("Personal Info")  
newdock.Tag = "~/UserControls/EditContact/PersonalInfo.ascx" 
LoadWidget(newdock)  
Me.rdzEditContact.Controls.Add(newdock)  
 
newdock = CreateRadDock("Custom Fields")  
newdock.Tag = "~/UserControls/EditContact/CustomFields.ascx" 
LoadWidget(newdock)  
Me.rdzEditContact.Controls.Add(newdock)  
 
 

Is there a way I can pass the common object to each of these controls on the page?

4 Answers, 1 is accepted

Sort by
0
License Developer
Top achievements
Rank 1
answered on 05 Sep 2008, 05:36 PM
I have the same situation and am interested in this also.
0
Sophy
Telerik team
answered on 08 Sep 2008, 10:29 AM
Hello,

I am not sure whether I understand you correctly. You can pass values to the UserControl you load in the RadDock in the standard ways - adding a property to the UserControl which you can access from the page in which you load the control, using the Session object to pass the needed values and etc and this does not depend on the RadDock control itself.
If you want to associate the information displayed in the dock with the RadDock control and save it in its state you can use the dock's Tag property. It accepts a string as a value, however, you can serialize and store more than one value as a string separated by semicolons, for example, and retrieve the values afterwards splitting this string, e.g.:
RadDock1.Tag = "string1;string2";  
string[] strings = RadDock1.Tag.Split(';'); 

In case the above explanation does not answer to your exact question, please, describe in more details what you want to achieve and what are the difficulties you encounter. We will be glad to help you.

Sincerely yours,
Sophy
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ThePope
Top achievements
Rank 1
answered on 11 Sep 2008, 02:12 PM
I was able to figure out how to pass data to the user control in the raddock by creating the usercontrol object in the code behind and adding it to the raddock.

My next question is how to get data back from the control on submission.

My scenario is two seperate raddock objects in a single raddockzone. Each raddock has a single usercontrol in it that display some information via textboxes. This information can be changed by the user and then saved by clicking an update button that is on the form, not on the individual usercontrols.

Right now the two raddock objects are added in the page init, so when I get to the buttonclick handler, the fields have either been reset or are blank.

Since the user controls are added in page init, is there a way to persist the data enter into the usercontrol when the page is submitted?
0
Sophy
Telerik team
answered on 15 Sep 2008, 12:56 PM
Hi Patrick,

The problem you experience that the input value entered in the textboxes inside the RadDock not being saved after a postback (page submit in your case) is most probably due to specifying different ids every time you are creating the docks. If you create RadDocks with the same ids to their initial ones after the postback the behavior you describe will automatically be applied. For your convenience I have attached a sample test app which demonstrates how the desired functionality could be achieved.
If you need further assistance, do contact us again.

Best wishes,
Sophy
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Dock
Asked by
ThePope
Top achievements
Rank 1
Answers by
License Developer
Top achievements
Rank 1
Sophy
Telerik team
ThePope
Top achievements
Rank 1
Share this question
or