我怎么能知道,如果一个非必须RenderSection的存在? [英] How can I know if a non-required RenderSection exists?
本文介绍了我怎么能知道,如果一个非必须RenderSection的存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@ *略code .. * @
@RenderBody()
@RenderSection(侧边栏,必需:false)
有没有办法在略code
部分知道如果RenderSection 补充工具栏
的存在与否?
解决方案
@if(IsSectionDefined(侧边栏))
{
@RenderSection(侧栏)
}
其他
{
< DIV>一些默认的内容和LT; / DIV>
}
@* Omitted code.. *@
@RenderBody()
@RenderSection("Sidebar", required: false)
Is there any way to know in the Omitted code
part if the RenderSection Sidebar
exists or not?
解决方案
@if (IsSectionDefined("Sidebar"))
{
@RenderSection("Sidebar")
}
else
{
<div>Some default content</div>
}
这篇关于我怎么能知道,如果一个非必须RenderSection的存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文