Passing parameters to UserControl

  1. #1

    Passing parameters to UserControl


    I'm using UserControl in my page like that:

                    foreach (var price in PricesInPriceList)
                        var matrix = new UserControlLoader()
                        { Path = "UserControls/FuelPriceUpdateMatrix.ascx", UserControlID = "Matrix" + price.ItemId };
                        var matrixContainer = new Container();
    The .aspx looks like that:

      <ext:Container MarginSpec="10, 20,10,10" Flex="5" ID="FuelItemsMatrices"
                                        runat="server" Layout="VBoxLayout">
                                            <ext:VBoxLayoutConfig Align="StretchMax" />

    I'm rendering those user controls on page load and also inside direct method (when some button pressed)

    the problem:

    I want to set the UserControl parameters before it rendered.
    I saw that you need to do something like that:

    MyUserControl uc = (MyUserControl)UserControlRenderer.LoadControl(path);
    uc.Property1 = "value1";
    var s =ComponentLoader.ToConfig(uc);
    return s;

    But i dont understand how its works i.e. what i am doing with the string s?
    how i am put this user control inside FuelItemsMatrices warpped up in his own container?
  2. #2
    Hello @eitanby!

    The s in your code probably returns a JavaScript object representation of an ExtJS component set up on that MyUserControl class. Probably from a componentLoader call (a panel with a loader inside, for example), the s config object will be evaluated and (if the control is correctly set up) render the component on the client side.

    But this is as far as I can tell about your issue, I can't really build up your scenario with the information you provided here.

    I hope this (somehow) helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] RowSelectionModel passing parameters in v3
    By jmilton in forum 3.x Legacy Premium Help
    Replies: 2
    Last Post: May 12, 2015, 7:06 PM
  2. Passing parameters in UserControlLoader
    By maxdiable in forum 2.x Help
    Replies: 1
    Last Post: Aug 26, 2013, 6:06 PM
  3. Passing parameters - UserControlLoader
    By ontiv in forum 2.x Help
    Replies: 1
    Last Post: Jul 09, 2013, 5:52 AM
  4. [CLOSED] AutoLoad - passing parameters
    By PLoch in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 11, 2011, 10:47 PM
  5. Passing parameters with HttpProxy / Store
    By Washburn in forum 1.x Help
    Replies: 1
    Last Post: Jan 12, 2009, 6:18 AM

Tags for this Thread

Posting Permissions