This is the code which I have in my partial view
@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")
}
Please note at the bottom of my code, I've got a @section
, and I realized that it's not running if I set a breakpoint there. If I move that line in the _Layout.cshtml it works well, but that's not the idea.
How can I tell to MVC4 in a partial razor view that I want to add that library?
You can't render layout sections from a partial. Move the section definition to the parent page or layout.