Default Content for Section in Razor
Asked Answered
S

2

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

Solvolysis answered 14/5, 2011 at 12:48 Comment(0)
W
13

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

Wychelm answered 14/5, 2011 at 13:6 Comment(1)
tl;dr: No but you can haack it in if you are desperateDisrobe
M
19
@RenderSection("nameOfSection", required: false)
@if (!IsSectionDefined("nameOfSection"))
{
    <div>Default section content</div>
}
Metametabel answered 15/11, 2016 at 12:56 Comment(0)
W
13

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

Wychelm answered 14/5, 2011 at 13:6 Comment(1)
tl;dr: No but you can haack it in if you are desperateDisrobe

© 2022 - 2024 — McMap. All rights reserved.