Reputation: 4251
I need your help, I have written this code to render the "~/bundles/jqueryval"
The view Code
@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")
}
Master Page Code
<!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">
but unfortunately I get this error
The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/MasterPage.cshtml": "Scripts".
so please could anyone help me to resolve this problem.
Upvotes: 1
Views: 4254
Reputation: 56429
You need to declare the section within your "master page":
@RenderSection("Scripts", false)
Probably the best idea to include this in the head
tag.
Otherwise it doesn't know what to do with your Scripts
section defined in your child view.
The second parameter, which I've set to false
is whether or not the section is required. If you set this to true and one of your child pages doesn't contain the section, you'll get a server error complaining that the section is missing.
Upvotes: 1