How can I know if a non-required RenderSection exists?

后端 未结 1 902
夕颜
夕颜 2020-12-24 04:34
@* Omitted code.. *@
@RenderBody()
@RenderSection(\"Sidebar\", required: false)

Is there any way to know in the Omitted code part if t

相关标签:
1条回答
  • 2020-12-24 04:51
    @if (IsSectionDefined("Sidebar"))
    {
        @RenderSection("Sidebar")
    }
    else
    {
        <div>Some default content</div>
    }
    
    0 讨论(0)
提交回复
热议问题