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

Passing parameters to Dynamically Created Docks

5 Answers 123 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Terry Webster
Top achievements
Rank 2
Terry Webster asked on 19 Nov 2007, 05:43 PM
I am trying to use the Dynamically Created Docks example at http://www.telerik.com/DEMOS/ASPNET/Prometheus/Dock/Examples/DynamicDocks/DefaultCS.aspx.  however, I need to be able to pass parameters from the parent page to the dynamically created docks.  My user controls have a public sub exposed called UpdateParameters(StartDate as Date, EndDate as Date, Client as String, Type as Integer).  I just need to be able to call this subroutine from the parent page for all loaded docks.

5 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 20 Nov 2007, 08:05 AM
Hello Terry Webster,

Before proceeding would it be possible for you to provide some more information about your scenario - are you loading user controls inside the dock as in this online demo? If not, please describe in more details your exact scenario so we can better assist you in achieving it and send us a simple running page in a support ticket demonstrating your settings so we can run it to see how you can pass the desired arguments.

Regards,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Terry Webster
Top achievements
Rank 2
answered on 20 Nov 2007, 02:45 PM
I am using that exact example. 
0
Petya
Telerik team
answered on 21 Nov 2007, 07:48 AM
Hi Terry Webster,

An appropriate place to pass some parameters to the user controls loaded in the docks is the LoadWidget method. There you obtain reference to the user control object in widget which you need to cast to the type of the user control class and in this way you can access widget's public properties/methods defined in the user control and pass them some parameters. Let me know if you need further assistance with this.

Kind regards,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Nag M
Top achievements
Rank 1
answered on 03 Jun 2010, 05:55 AM
Hi Telerik team,

I have an issue with dynamically created docks.
I want to access the Dynamically created user control properties in my aspx page from code behind.
I am using the Dock - Control My portal example. I am able to set the values to User control properties in LoadWidget. But the problem is I am unable to get the updated/modified values from the User control. Where can I write the code to get the values from user control?
LoadWidget is always called when user make any changes to the control. but I am setting the values in that section for the control. For getting values .. I m not able to find a solution. Also I could access the UniqueID of dynamically created control outside the LoadWidget.

Please suggest any better way to retrieve the values from the user control.

Scenario: C#

private

 

void LoadWidget(RadDock dock)  

 

 

{

 

 

 

if (string.IsNullOrEmpty(dock.Tag))

 

{

 

return;

}

 

 

Control widget = LoadControl(dock.Tag);

 

dock.ContentContainer.Controls.Add(widget);

 

 

// ((ChartDashboard)widget).SelectedInput = dock.Text ;    Set the value to User control ...

 

 

 

string ucText = ((ChartDashboard)widget).SelectedInput;  // Not getting any value. Always returns null

 

}

 


I want to access this dynamically created control's property in my Save_Click event .... Is it possible?

Thanks,
Nag
0
Pero
Telerik team
answered on 08 Jun 2010, 12:15 PM
Hi Nag,

There are a couple of ways to access the user control loaded in the content container of the dock:
  • Use dock.ContentContainer.Controls collection to access the respective control. Usually the loaded control is at index 1.
  • You could create a custom class that inherits from RadDock, and create a property that will hold a reference to the user control loaded within the dock.
  • Set an ID to the user control, and then use the dock.ContentContainer.FindControl(ID) to get a reference to the control.
For your convenience I implemented the last approach, and attached the sample project to the thread. Here is the method that loads the widget, and assigns the value of the custom property to the Text property of a Label:

protected void Page_Load(object sender, EventArgs e)
{
    RadDock1.Tag = "~/User_Control_DOCK.ascx";
    LoadWidget(RadDock1);
 
    CustomProperty.Text = ((User_Control_DOCK)RadDock1.ContentContainer.FindControl("UserControl_dock")).CustomProperty;
}
 
private void LoadWidget(RadDock dock)
{
    Control widget = LoadControl(dock.Tag);
    widget.ID = "UserControl_dock";
    dock.ContentContainer.Controls.Add(widget);
 
    ((User_Control_DOCK)widget).CustomProperty = "added at: " + DateTime.Now.ToString();
}


Sincerely yours,
Pero
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Dock
Asked by
Terry Webster
Top achievements
Rank 2
Answers by
Petya
Telerik team
Terry Webster
Top achievements
Rank 2
Nag M
Top achievements
Rank 1
Pero
Telerik team
Share this question
or