Determining if RenderSection () was called on the Layout page

Is there a way in the layout to determine if it will display content?

@RenderSection ("Right", required: false)

This determines whether there is content in the view for placement in the section.

+5
source share
1 answer

Probably not quite answering your question about testing if the section will display some content, but you can check if the section is defined and visualize it or provide default content if this section is not defined:

@if (IsSectionDefined("Right")) { 
    @RenderSection("Right")
}
else { 
    <div>Default content</div>
}
+13
source

All Articles