我遇到了一个问题,由于搜索我已经发现在我的布局中放置@RenderSection("SectionName")
但是即使异常刚刚弹出也不知道如何处理它。
这是我视图中定义的部分。
@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>
}
这是布局代码:
@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>
任何建议或提示都将不胜感激,提前致谢。
编辑1: 当我将布局添加到视图时,我的视图没有使用布局,另一个错误显示出来。错误是未定义的部分:“脚本”。
答案 0 :(得分:2)
如果您有一个可选的部分,则需要将required
标志设置为false来呈现它:
@RenderSection("scripts", required: false)