PDA

View Full Version : [CLOSED] Razor syntax for adding a partial view to a Panel



machinableed
Feb 22, 2012, 11:34 PM
Hi there,

I'm having some trouble adding a partial view as the content for a Panel. What is the correct syntax for this? For example if I have a partial view "_partial.cshtml" and i want it to be the content of a panel?

I've tried variations on the following no luck:


Html.X().Panel()
.Region(Region.West)
.Width(225)
.CollapseMode(CollapseMode.Mini)
.Margins("0 0 4 4")
.Content("/views/shared/_partial.cshtml")

thanks,

Daniil
Feb 23, 2012, 9:55 AM
Hi,

There is no Razor partial view support in DP1, but this functionality has been already added and will be available with the next release.

You will be able to use some of these methods: ContentFromPage, ContentFromSection, ItemsFromPage, ItemsFromSection.

Here is the example with ItemsFromPage.

Example Main View

@{
Layout = "";
}
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
</head>
<body>
@Html.X().ResourceManager().Theme(Theme.Gray)

<h1>Panel 2</h1>

@(
Html.X().Panel()
.Title("Panel 1")
.Width(400)
.Height(400)
.Icon(Icon.Add)
.Layout(LayoutType.Accordion)
.ItemsFromPage(this, "~/Views/Items/SubPage.cshtml")
)

<h1>Panel 2</h1>

@(
Html.X().Panel()
.Title("Panel 2")
.Width(400)
.Height(400 )
.Icon(Icon.Application)
.Layout(LayoutType.Accordion)
.ItemsFromPage(this, "~/Views/Items/SubPage.cshtml")
)
</body>
</html>



Example Partial View

@(Html.X()
.Panel()
.Title("SubPage - Panel 1")
.Height(150)
.Icon(Icon.BulletPlus)
)

@(Html.X()
.Panel()
.Title("SubPage - Panel 2")
.Height(150)
.Icon(Icon.BulletMinus)
)

@(Html.X()
.Panel()
.Title("SubPage - Panel 3")
.Height(150)
.Icon(Icon.BulletStar)
)