开发者

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

开发者 https://www.devze.com 2023-03-21 16:12 出处:网络
@* Omitted code.. *@ @RenderBody() @RenderSection(\"Sidebar\", required: false) Is there any way to know in the Omitted code part if the RenderSection Sid开发者_StackOverflowebar exists or not?@if (
@* Omitted code.. *@
@RenderBody()
@RenderSection("Sidebar", required: false)

Is there any way to know in the Omitted code part if the RenderSection Sid开发者_StackOverflowebar exists or not?


@if (IsSectionDefined("Sidebar"))
{
    @RenderSection("Sidebar")
}
else
{
    <div>Some default content</div>
}
0

精彩评论

暂无评论...
验证码 换一张
取 消