[CLOSED] UserControlLoader with properties

  1. #1

    [CLOSED] UserControlLoader with properties

    Hi,

    Is it possible to use an UserControlLoader to load an User Control with public properties? Or UserControlLoader could only be used passing request parameters?

    We would like to perform something like that:

    Sample.ascx

    <script runat="server">
        public string RouteUrl { get; set; }
        public int Type{ get; set; }
    </script>
    View.aspx

    <ext:Panel ID="pnlSample" runat="server" Layout="FitLayout" Border="false" Title="Sample">
        <Content>
            <Test:Sample ID="ctrlSample" runat="server" RouteUrl='<%# string.Format("~/Sample/Edit/{0}", Model.ID) %>' Type="3" />
        </Content>
    </ext:Panel>
    Thanks.
    Last edited by Daniil; Oct 22, 2012 at 1:12 PM. Reason: [CLOSED]
  2. #2
    Hi @softmachine2011,

    You can handle the UserControlLoader UserControlAdded event to initialize a user control.
  3. #3
    Can you please provide an example of how to do that? I see no reason why properties cannot be passed in when you can even do this with LoadControl.
  4. #4
    Hello @michaeld,

    Well, the question was how to do it with a UserControlRender.

    Example
    protected void OnUserControlAdded(object sender, UserControlAddedEventArgs e)
    {
        e.UserControl.ID = "UserControl1";
    }
    <ext:UserControlLoader runat="server" Path="..." OnUserControlAdded="OnUserControlAdded" />
    If you use the LoadControl method, then yes, there is no any problem.
  5. #5
    Your example uses a Control property [ID], so it works without challenge. The original example shows accessible properties related to the actual control. The problem becomes an out of scope build order problem if you try to cast e.UserControl to your control's type to access its members, it may not have been built yet. Ideas?
    Last edited by michaeld; Mar 31, 2013 at 10:00 AM.
  6. #6
    Quote Originally Posted by michaeld View Post
    if you try to cast e.UserControl to your control's type to access its members, it may not have been built yet.
    Sorry, I didn't understand well what you mean. Could you clarify, please? Probably, a code sample would be best.
  7. #7
    The environment could not be easily presented as an example. However I had to switch from WSP to WAP.
  8. #8
    Quote Originally Posted by michaeld View Post
    However I had to switch from WSP to WAP.
    Sorry, we didn't quite understand what you mean here. Could you clarify, please?

Similar Threads

  1. Passing parameters - UserControlLoader
    By ontiv in forum 2.x Help
    Replies: 1
    Last Post: Jul 09, 2013, 5:52 AM
  2. [CLOSED] UserControlLoader : ID vs UserControlID
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 01, 2012, 9:35 PM
  3. [CLOSED] Issue using UserControlLoader
    By amitpareek in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Sep 13, 2012, 8:09 AM
  4. [CLOSED] UserControlLoader and Content
    By thchuong in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 11, 2012, 8:03 AM
  5. [CLOSED] ext.UserControlLoader in CodeBehind
    By supera in forum 2.x Legacy Premium Help
    Replies: 16
    Last Post: Feb 07, 2012, 5:14 PM

Posting Permissions