16

I want to have some default content for a section let suppose Footer. How can I do this.

Also, what if I want to render a partial view as the default content.

Thanks

Shakeeb Ahmed
  • 1,778
  • 1
  • 21
  • 37

2 Answers2

19
@RenderSection("nameOfSection", required: false)
@if (!IsSectionDefined("nameOfSection"))
{
    <div>Default section content</div>
}
Mariusz Jamro
  • 30,615
  • 24
  • 120
  • 162
Bahtiyar Özdere
  • 1,818
  • 17
  • 21
13

Haacked blogged about this http://haacked.com/archive/2011/03/05/defining-default-content-for-a-razor-layout-section.aspx.

Necros
  • 3,004
  • 23
  • 29