Reputation: 14879
In my Master I have a section with default content:
@section BlahBlah {
<p>Hello world!</p>
}
Now in my view pages, for some of them, I want to hide this section completely.
How can I do this?
Upvotes: 0
Views: 57
Reputation: 69983
There is a built in function called IsSectionDefined
that will let you default the content if the given section name hasn't been defined. You can see this blog post for more details.
@if(IsSectionDefined("BlahBlah")) {
@RenderSection("BlahBlah")
} else {
<p>Hello world!</p>
}
Upvotes: 3