[CLOSED] MVC Razor ContentFromSection

  1. #1

    [CLOSED] MVC Razor ContentFromSection

    Hello,

    Just curious how to use the ContentFromSection, or ContentFromPage on a Panel in MVC 3 Razor?

    I've got the following:

    @(Html.X().Viewport()
        .Border(false)
        .Layout(Ext.Net.LayoutType.Fit)
        .Items(a =>
            a.Add(Html.X().Panel()
                .Border(false)
                .ContentFromSection( ... )
            )
        )
    )
    I noticed the first parameter is of WebPageBase.

    Any example appreciated :)

    Cheers
    Last edited by Daniil; Apr 30, 2012 at 8:01 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Here you are.

    ItemsFromSection Example

    Example Layout View
    <!DOCTYPE html>
    <html>
    <head>
        <title>@ViewBag.Title</title>    
    </head>
    <body>    
        @Html.X().ResourceManager()
    
        @(Html.X().Panel()
            .Title("Panel1")
            .Width(400)
            .Height(400)
            .Icon(Icon.Add)
            .Layout(LayoutType.Accordion)
            .ItemsFromSection(this, "section1")        
        )
    
        @(Html.X().Panel()
            .Title("Panel2")
            .Width(400)
            .Height(400)
            .Icon(Icon.Application)
            .Layout(LayoutType.Accordion)
            .ItemsFromSection(this, "section2")        
        )
    </body>
    </html>
    Example View (which used the layout view above)
    @{
        ViewBag.Title = "ItemsFromSection";
        Layout = "~/Views/Test/LayoutSection.cshtml";
    }
    
    @section section1{
         @(Html.X().Panel()
            .Title("Section 1 - Panel 1")       
            .Height(150) 
            .Icon(Icon.BulletPlus)
         )
    
         @(Html.X().Panel()
            .Title("Section 1 - Panel 2")       
            .Height(150) 
            .Icon(Icon.BulletMinus)
         )
         
         @(Html.X().Panel()
            .Title("Section 1 - Panel 3")       
            .Height(150) 
            .Icon(Icon.BulletStar)
         )
    }
    
    
    @section section2{
         @(Html.X().Panel()
            .Title("Section 2 - Panel 1")
            .Height(150) 
            .Icon(Icon.BulletPlus)
         )
         
         @(Html.X().Panel()
            .Title("Section 2 - Panel 2")
            .Height(150) 
            .Icon(Icon.BulletMinus)
         )
         
         @(Html.X().Panel()
            .Title("Section 2 - Panel 3")
            .Height(150) 
            .Icon(Icon.BulletStar)
         )
    }
    Last edited by Daniil; Apr 30, 2012 at 7:36 PM.
  3. #3
    ItemsFromPage Example

    Example 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/Test/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/Test/SubPage.cshtml")
            )
    </body>
    </html>
    Example Child View (SubPage.cshtml)
    @(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)
    )
  4. #4
    Great examples, thank you very much for your time!

    Cheers,
    Timothy
  5. #5
    These examples have been already done by Vladimir :) I just posted them.

    They should be available for all soon.
  6. #6
    I found my issue again...razor can be very problematic...there was a space between my
    @Html.X  ( )
    "Html.X" and the opening bracket. Why can't razor parse out a space?...it is parsing c#?

    Thanks.
  7. #7
    Hello @edip,

    It would be best to start a new thread.
    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] [RAZOR] DraggablePanelConfig doesn't have StartDrag in Razor
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 28, 2012, 2:37 PM
  2. [CLOSED] [Razor] HyperLink Text in Razor
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 20, 2012, 12:16 PM
  3. [CLOSED] [Razor] Add GridView to GridPanel in razor
    By boris in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 09, 2012, 4:23 PM
  4. [CLOSED] [Razor] Setup Auto load panel in razor
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 27, 2012, 10:54 AM
  5. [CLOSED] Razor Example
    By jesperhp in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 27, 2012, 9:49 AM

Tags for this Thread

Posting Permissions