[CLOSED] Fill layout region with partial view

  1. #1

    [CLOSED] Fill layout region with partial view

    I have to separate the UI code in small pieces using MVC razor views.

    I'm wondering if I can split the core of my app as different views organized in a BorderLayout. I'd like to dynamically build the different regions of my BorderLayout using different views. Example Region.Nord composed by "/Home/Toolbar", region.West filled by "/Home/Menu" and so on.
    I've got successfully built the border layout but I don't know ho to fill regions using partial views. I tried different strategies like the one below

    (mypanel).Html(Html.Partial("/Views/Home/Toolbar.cshtml").ToHtmlString()
    but no success, any hints?

    Thanks
    Mario
    P.S. also tried
    LoadExtContent
    but I got an exception: cannot convert webpage to razor page
    Last edited by Daniil; Apr 09, 2012 at 6:58 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please use the ItemsFromPage property.

    Example Main View
    @{
         Layout = "";
    }
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>@ViewBag.Title</title>    
    </head>
    <body>    
        @Html.X().ResourceManager()
    
        @(Html.X().Viewport()
            .Layout(LayoutType.Border)
            .Items(items =>
            {
                items.Add(Html.X().Panel()
                    .Title("North")
                    .Region(Region.North)
                    .Height(100)
                    .ItemsFromPage(this, "~/Views/Test/NorthRegion.cshtml")
                );
                items.Add(Html.X().Panel()
                    .Title("Center")
                    .Region(Region.Center)
                    .ItemsFromPage(this, "~/Views/Test/CenterRegion.cshtml")
                );
            })
        )
    </body>
    </html>
    Example CenterRegion.cshtml
    @(Html.X().Container()
        .Html("I am Center!")
    )
    Example NorthRegion.cshtml
    @(Html.X().Container()
        .Html("I am North!")
    )

Similar Threads

  1. [CLOSED] Loading Partial View under a formpanel
    By Daly_AF in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 25, 2012, 2:26 PM
  2. [CLOSED] Partial View Error
    By peter.campbell in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 10, 2012, 10:32 AM
  3. [CLOSED] Partial View & FormPanel Submit
    By peter.campbell in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 14, 2011, 12:01 PM
  4. [CLOSED] RegisterOnReadyScript in MVC partial view
    By SandorD in forum 1.x Legacy Premium Help
    Replies: 22
    Last Post: Aug 10, 2011, 4:17 PM
  5. [CLOSED] MVC- How to display a Partial View from a window
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Apr 08, 2011, 11:32 AM

Posting Permissions