PDA

View Full Version : [CLOSED] Fill layout region with partial view



bbo1971
Apr 04, 2012, 12:11 PM
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

Daniil
Apr 04, 2012, 3:12 PM
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!")
)