Question

<div class="welcome">                      
      <asp:ContentPlaceHolder runat="server" ID="FeaturedContent" />
      <div style="margin: 10px 0;">
          <asp:ContentPlaceHolder runat="server" ID="MainContent" />
      </div>
      <!-- etc -->
</div>

I have master page in asp.net project which have two content place holder? Now i am trying to create. this project in MVC how to to take two content place holder in _Layout.cshtml. So at derived page i can put my content's in between this.

Was it helpful?

Solution

Razor also supports the ability to add additional "named sections” to layout templates as well. These sections can be defined anywhere in the layout file (including within the section of the HTML), and allow you to output dynamic content to multiple, non-contiguous, regions of the final response.

Read below link : http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx enter image description here

OTHER TIPS

 <div class="welcome">                      
                     @RenderSection("featured", required: true)
                        <div style="margin: 10px 0;">
                              @RenderSection("MainContent", required: true)
                        </div>
                                @RenderBody()
                        <div class="c">
                        </div>
                    </div>

and in inherited page

@section MainContent
{
    <h1>MainContent</h1>
}
@section featured
{
    <h1>feaured</h1>
}

Thank You Kumar Manish

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top