我正在尝试找出正确的Razor语法,以便将特定*.cshtml的JavaScript文件与_Layout.cshtml中定义的所有其他包含文件一起放在head标记中.
这是我在局部视图中的代码
@model Contoso.MvcApplication.Models.Exercises.AbsoluteArithmetic
@using(Html.BeginForm())
{
<div>
<span style="width: 110px; float:left; text-align:center; font-size:2.5em;">@Model.Number1</span>
<span style="width: 110px; float:left; text-align:center; font-size:2.5em;">+</span>
<span style="width: 110px; float:left; text-align:center; font-size:2.5em;">@Model.Number2</span>
<span style="width: 110px; float:left; text-align:center; font-size:2.5em;">=</span>
<span>
@Html.EditorFor(model => model.Result)
@Html.ValidationMessageFor(model => model.Result)
</span>
</div>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Run Code Online (Sandbox Code Playgroud)
请注意我的代码底部,我有一个@section,我意识到如果我在那里设置一个断点,它就不会运行.如果我在_Layout.cshtml中移动该行,则效果很好,但这不是主意.
如何在部分剃刀视图中告诉MVC4我想添加该库?