如何在MVC4局部视图中添加脚本? [英] How to add a script in a partial view in MVC4?
本文介绍了如何在MVC4局部视图中添加脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是code,我有我的局部视图
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")
}
请注意我的code的底,我有一个 @section
,我意识到,它没有运行,如果我设置一个断点。如果我搬进它运作良好的_Layout.cshtml那行,但是这不是想法。
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.
我怎么能告诉MVC4中,我想补充一点,库中的部分剃刀看法?
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.
这篇关于如何在MVC4局部视图中添加脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文