什么是@RenderSection在asp.net MVC [英] what is @RenderSection in asp.net MVC
本文介绍了什么是@RenderSection在asp.net MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
的目的是什么,它是如何function.I明白捆绑做,但我还没有搞清楚这是什么一样和它可能是很重要的。
What is the purpose and how does it function.I understand what bundles do but i have yet to figure out what this does and its probably important.
@RenderSection("scripts", required: false)
也许就如何使用它的一个小例子?
perhaps a small example on how to use it?
推荐答案
如果你有一个这样的_Layout.cshtml视图
If you have a _Layout.cshtml view like this
<html>
<body>
@RenderBody()
@RenderSection("scripts", required: false)
</body>
</html>
那么你可以有一个这样的index.cshtml内容视图
then you can have an index.cshtml content view like this
@section scripts {
<script type="text/javascript">alert('hello');</script>
}
的需要的指示是否使用布局页必须有一个脚本部分视图
the required indicates whether or not the view using the layout page must have a scripts section
这篇关于什么是@RenderSection在asp.net MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文