我需要您的帮助,我编写了这段代码来呈现“~/bundle/jqueryval”
视图代码
@model workflow.DataHolders.NewCompany
<link href="@Url.Content("~/sharedfiles/css/forms/addnew.css")" rel="stylesheet" type="text/css" />
<div id="Add_container">
@if (!ViewData.ModelState.IsValid)
{
<div id="validationMessage">Please Correct The Errors Below</div>
}
@using (Html.BeginForm("ValidateAndSignUp", "Accounts", FormMethod.Post))
{
@Html.AntiForgeryToken()
@Html.ValidationMessage("CompanyName");
<span class="field_title">Company Name: </span>
@Html.TextBox("CompanyName")
@Html.ValidationMessage("Email");
<span class="field_title">Email: </span>
@Html.TextBox("Email")
@Html.ValidationMessage("Country");
<span class="field_title">Country Name: </span>
@Html.TextBox("Country")
<span class="field_title">About The Company: </span>
@Html.TextArea("Description")
<input type="submit" value="Create New Account">
}
</div>
<div class="get_connected_message">
<h1>Get Connected with your Customers</h1>
</div>
<div class="get_connected_message">
<h1>Build your profissional buisness world</h1>
</div>
<div class="clear"></div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}母版页代码
<!DOCTYPE html>
<html>
<head>
<title>MACE CRM</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="/workflow/sharedfiles/css/reset.css">
<link rel="stylesheet" type="text/css" href="/workflow/sharedfiles/css/main.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
@Html.Partial("~/Views/shared/header.cshtml")
<center id="body_container">
<div id="content">
@RenderBody()
</div>
</center>
@Html.Partial("~/Views/shared/footer.cshtml")
</body>
</html>
<link rel="stylesheet" href="/workflow/sharedfiles/css/smartDevicesVersion.css">但不幸的是我得到了这个错误
已经定义了以下部分,但尚未为布局页“~/Views/Shared/MasterPage.cshtml”呈现:“脚本”。
所以请任何人帮我解决这个问题。
发布于 2015-06-18 10:02:15
您需要在“母版页”中声明该节:
@RenderSection("Scripts", false)在head标记中包括这一点可能是最好的主意。
否则,它不知道如何处理您在子视图中定义的Scripts部分。
我已设置为false的第二个参数是是否需要该节。如果您将此设置为true,并且您的一个子页面不包含该部分,您将得到一个服务器错误,抱怨该部分丢失。
https://stackoverflow.com/questions/30912244
复制相似问题