[CLOSED] Razor syntax for adding a partial view to a Panel

  1. #1

    [CLOSED] Razor syntax for adding a partial view to a Panel

    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,
    Last edited by Daniil; Feb 27, 2012 at 10:20 AM. Reason: [CLOSED]
  2. #2
    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)
    )

Similar Threads

  1. [CLOSED] Loading panel with MVC partial view
    By bbo1971 in forum 2.x Legacy Premium Help
    Replies: 26
    Last Post: Jul 25, 2012, 1:04 AM
  2. Replies: 4
    Last Post: Apr 09, 2012, 2:10 PM
  3. Replies: 2
    Last Post: Mar 13, 2012, 10:23 AM
  4. [CLOSED] Tree Panel Razor View Example?
    By machinableed in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Mar 09, 2012, 8:22 AM
  5. [CLOSED] Dynamically adding view to panel MVC
    By RCM in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 14, 2011, 6:19 PM

Posting Permissions