[CLOSED] MVC - Loading UserControl's with PartialViewResult

  1. #1

    [CLOSED] MVC - Loading UserControl's with PartialViewResult

    Hi @all,

    I load on clientside with jscript UserControls in Asp - Repeater.

    Here some code snippets to understand the situation.

    .js
    var p_new_item = new Ext.Panel({
            id: name_control,
            layout: 'fit',
            border: false
        });
    
        var p_loader = new Ext.Panel({
            id: name_loader,
            border: false,
            hidden: true,
            loader: {
                url: url,
                disableCaching: true,
                scripts: true,
                params: {
                    containerId: p_new_item.id,
                    contSID: contSID
                }
            }
        });
        
        p_list.add(p_loader);
        p_list.add(p_new_item);
    .Controller.cs
    public ActionResult uc_ContText(string containerId, string contSID)
     {           
    
                this.ViewData["contSID"] = contSID;
    
                var pr = new Ext.Net.MVC.PartialViewResult(containerId);
                pr.ViewData = ViewData;
                pr.RenderMode = Ext.Net.RenderMode.AddTo;
                pr.SingleControl = true;
                pr.IDMode = Ext.Net.IDMode.Explicit;
               
                return pr;
            }
    That works with a UserControl (.ascx) which was developed with Ext.Net but not with UserControl with Asp-Code.
    If I build a ext:Panel around the asp-div, it works too!

    .ascx
    <ext:Panel runat="server">
        <Content>
             <div>
                    //My UserContol.....
             </div>
        </Content>
    </ext:Panel>
    How I can Asp-UserControls load without Ext.Net -Code ??
    Thanks!
    Last edited by Daniil; Jun 18, 2013 at 4:01 AM. Reason: [CLOSED]
  2. #2
    Hi @ontiv,

    I think you cannot use these options:
    pr.RenderMode = Ext.Net.RenderMode.AddTo;
    pr.SingleControl = true;
    if a partial view contains native ASP.NET controls on the top level.

    It would be simplest to wrap an ASP.NET control in an additional Ext.NET container.
    <ext:Container runat="server">
        <Content>
            <asp:Label runat="server" Text="Hello!" />
        </Content>
    </ext:Container>
    Also I would recommend you to use Mode="Component" for a Loader.

    Example

    Page
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.Net.MVC v2 Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <ext:Panel ID="Panel1" runat="server" Width="200" Height="200">
            <Loader runat="server" Mode="Component" Url="/Aspx/Partial" />
        </ext:Panel>
    </body>
    </html>
    Partial View
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    
    <ext:Container runat="server">
        <Content>
            <asp:Label runat="server" Text="Hello!" />
        </Content>
    </ext:Container>

    Controller Action

    public ActionResult Partial()
    {
        return Json(ComponentLoader.ToConfig("~/Views/Aspx/Partial.ascx"), JsonRequestBehavior.AllowGet);
    }
  3. #3
    Hi Daniil,

    thanks for your help.

Similar Threads

  1. Replies: 22
    Last Post: Feb 13, 2013, 7:59 AM
  2. [CLOSED] Loading userControls dinamically inside tabs
    By RogerioAquino in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 03, 2013, 4:20 PM
  3. [CLOSED] PartialViewResult
    By Z in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 23, 2012, 5:01 AM
  4. Replies: 4
    Last Post: Feb 01, 2012, 8:37 AM
  5. Replies: 7
    Last Post: Oct 28, 2011, 4:25 PM

Posting Permissions