加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 如何在MVC4的部分视图中添加脚本?

发布时间:2020-12-16 00:36:46 所属栏目:asp.Net 来源:网络整理
导读:这是我在部分视图中的代码 @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;
这是我在部分视图中的代码
@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")
}

请注意我的代码底部,我有一个@section,我意识到如果我在那里设置一个断点,它不会运行。如果我在_Layout.cshtml中移动该行,这很有效,但这不是想法。

如何在部分剃刀视图中告诉MVC4我想添加该库?

解决方法

您不能从部分渲染布局部分。将节定义移动到父页面或布局。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读