Render Dynamic Control in View

  1. #1

    Render Dynamic Control in View

    I have the following code which generates a dynamic control based on Model.ChildControlBaseID. However the rendered page seems to render control.ToString() and not the control's dom elements.

    @using Ext.Net
    @using Ext.Net.MVC
    @using cr.DomainObjects.Core
    @using common.Ext.Controls
    @model mfx.v3.ViewModels.DashboardBaseViewModel
    
    @{
        Layout = null;
        ViewBag.Title = "MFX - Route Management";    
        var X = Html.X();
        
    
        ControlModel controlModel = ControlHiearchyService_01.GetControlHierarchyDefinition(Model.ChildControlBaseID, Model.CurrentUser.UserID);
        controlModel.Request = this.Request.RequestContext;
        controlModel.CurrentUser = Model.CurrentUser;
    
        ControlBase control = controlModel.Controls.SingleOrDefault(t => t.ControlBaseID == Model.ChildControlBaseID);
        AbstractContainer ctr;
    
        if (control.ControlType == cr.DomainObjects.Core.ControlType.Container)
        {
            ctr = ControlHiearchyService_01.GetContainerDefinition(controlModel);
        }
        else if (control.ControlType == cr.DomainObjects.Core.ControlType.Panel)
        {
            ctr = ControlHiearchyService_01.GetPanelDefinition(controlModel);
        }
        else
        {
            ctr = ControlHiearchyService_01.GetGridPanelDefinition(controlModel);
        }
    
        ctr.Height = 1000;
        ctr.ViewContext = this.ViewContext;
        ctr.HtmlHelper = this.Html;
        ctr.Render(RenderMode.Auto);
        
    
    }
    
    
    <html>
    <head>
        <title>@ViewBag.Title</title>    
    
        <link href="~/content/css/crXOverride.css" rel="stylesheet" />
        <script src="~/content/js/common.js"></script>
    
        
    </head>
    <body>
        
        @Html.X().ResourceManager(ViewBag.ManagerConfig as MvcResourceManagerConfig)
    
        @ctr
    
    </body>
    </html>
  2. #2
    Hi @ehmdb,

    I just found your question in a non-premium forum. Being a premium member, please post technical support questions in a respective premium forum. Otherwise we can miss your question.

    Please clarify is the question still actual?

Similar Threads

  1. Render partial view with parameter
    By czuroski in forum 2.x Help
    Replies: 1
    Last Post: May 12, 2014, 6:43 PM
  2. [CLOSED] User Control Render dynamic value assign issue in page load
    By shaileshsakaria in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 26, 2014, 5:19 PM
  3. Replies: 2
    Last Post: Feb 06, 2014, 1:19 PM
  4. Replies: 0
    Last Post: Aug 23, 2013, 11:16 AM
  5. Dynamic grid does not render in a dynamic panel
    By Wellington Caetano in forum 1.x Help
    Replies: 4
    Last Post: Apr 12, 2011, 9:19 PM

Posting Permissions