Passing Data To a UserControl in a dock object

5 posts, 0 answers
  1. ThePope
    ThePope avatar
    39 posts
    Member since:
    Mar 2007

    Posted 03 Sep 2008 Link to this post

    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?
  2. License Developer
    License Developer avatar
    5 posts
    Member since:
    Jan 2008

    Posted 05 Sep 2008 Link to this post

    I have the same situation and am interested in this also.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 08 Sep 2008 Link to this post

    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.
  5. ThePope
    ThePope avatar
    39 posts
    Member since:
    Mar 2007

    Posted 11 Sep 2008 Link to this post

    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?
  6. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 15 Sep 2008 Link to this post

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