Reputation:
I have run into a problem, as a result of searching i have found out to place a @RenderSection("SectionName")
in my layout but even that the exception is just popping out don't know how to handle it.
Here is the section defined in my view.
@section scripts{
<script src="~/Scripts/infiniteScroll.js"></script>
<script type="text/javascript">
$(function () {
$("div#loading").hide();
});
var moreRowsUrl = "/InfiniteScrollDemo/GetCustomers"; //the URL to your ActionMethod
//var moreRowsUrl = ' Url.RouteUrl("CustomerList")'; //if you have a route defined, you can use an Html helper like Url.RouteUrl
$(window).scroll(scrollHandler);
</script>
}
and here is the layout code:
@using Microsoft.AspNet.Identity
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="The First Online Shopping Mall in Afghanistan">
<meta name="author" content="Naser Dostdar">
<title>@ViewBag.Title Online Shopping Center</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<link href="~/Content/font-awesome.min.css" rel="stylesheet" />
<link href="~/Content/prettyPhoto.css" rel="stylesheet" />
<link href="~/Content/price-range.css" rel="stylesheet" />
<link href="~/Content/animate.css" rel="stylesheet" />
<link href="~/Content/main.css" rel="stylesheet" />
<link href="~/Content/responsive.css" rel="stylesheet" />
<link rel="shortcut icon" href="images/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="images/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="images/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="images/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="images/ico/apple-touch-icon-57-precomposed.png">
</head>
<body>
<div>
@RenderBody()
</div>
@RenderSection("scripts")
<script src="~/Scripts/jquery.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="~/Scripts/jquery.scrollUp.min.js"></script>
<script src="~/Scripts/price-range.js"></script>
<script src="~/Scripts/jquery.prettyPhoto.js"></script>
<script src="~/Scripts/main.js"></script>
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
</body>
</html>
Any suggestion or hints would be appreciated, Thanks in advance.
Edit 1: My view was not using the Layout when i added the Layout to the view another error is showing up. The error is Section not defined: "scripts".
Upvotes: 0
Views: 183
Reputation: 8781
If you have a section that is optional, you need to render it with required
flag set to false:
@RenderSection("scripts", required: false)
Upvotes: 2