Passing parameters to Dynamically Created Docks

6 posts, 0 answers
  1. Terry Webster
    Terry Webster avatar
    48 posts
    Member since:
    Aug 2003

    Posted 19 Nov 2007 Link to this post

    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.

  2. Petya
    Admin
    Petya avatar
    869 posts

    Posted 20 Nov 2007 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Terry Webster
    Terry Webster avatar
    48 posts
    Member since:
    Aug 2003

    Posted 20 Nov 2007 Link to this post

    I am using that exact example. 
  5. Petya
    Admin
    Petya avatar
    869 posts

    Posted 21 Nov 2007 Link to this post

    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
  6. Nag M
    Nag M avatar
    4 posts
    Member since:
    May 2010

    Posted 03 Jun 2010 Link to this post

    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
  7. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 08 Jun 2010 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017