问题:
给定这样的嵌套布局结构:
~/Views/Shared/_layoutBase.cshtml ~/Views/Shared/_layout.cshtml
其中_layoutBase.cshtml
是_layout.cshtml
的布局。
任何在布局文件中定义的部分都可以在~/Views/...
下的页面中呈现其内容。
然而,对于区域中的视图,这些部分永远不会被呈现。
设置:
_layoutBase
:
<script type="text/javascript">
@RenderSection("footerScripts", false)
</script>
</body>
</html>
_layout.cshtml
:
@section footerScripts{
@RenderSection("footerScripts", false)
}
"内容"视图:
@section footerScripts{
$(function () {
SetFocusOnForm("CaptchaCode", "NextButton");
});
}
在区域中,footerScripts
部分的内容不会在视图中呈现。但是它会在位于 ~/Views
文件夹下的视图中呈现。
区域的 _ViewStart.cshtml
文件:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
问题:
您看到任何错误吗?!