-1

我收到一个错误:当我尝试运行我的索引页面时,它会抛出一个错误,我应该在我的索引视图页面中添加什么?以下部分已定义但尚未为布局页面“~/Views/Shared/_blanklayout.cshtml”呈现:“JavaScript”。

这是我的 _blacklayout 页面

@{
    Layout = null;
}
 <link type="text/css" rel="stylesheet" href="@Url.Content("~/content/reset.css")">
    <link type="text/css" rel="stylesheet" href="@Url.Content("~/content/layout.css")">
    <link type="text/css" rel="stylesheet" href="@Url.Content("~/content/core.css")">
@RenderBody()
<script type="text/javascript">
    adroll_adv_id = "6MFN5K54DVCUROYTS4BE5J";
    adroll_pix_id = "GR7KUS3M3FA7BE2HPTH5EX";
    (function () {
        var oldonload = window.onload;
        window.onload = function () {
            __adroll_loaded = true;
            var scr = document.createElement("script");
            var host = (("https:" == document.location.protocol) ? "https://s.adroll.com" : "http://a.adroll.com");
            scr.setAttribute('async', 'true');
            scr.type = "text/javascript";
            scr.src = host + "/j/roundtrip.js";
            ((document.getElementsByTagName('head') || [null])[0] ||
    document.getElementsByTagName('script')[0].parentNode).appendChild(scr);
            if (oldonload) { oldonload() }
        };
    } ());
    </script>
    <script type="text/javascript">

        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-19362393-2']);
        _gaq.push(['_setDomainName', 'netdocuments.com']);
        _gaq.push(['_trackPageview']);

        (function () {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();

</script>


**and this is my Index view page where I am using it:**

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_blanklayout.cshtml";
}

@section JavaScript{

 <script type="text/javascript">
     $(function () {
         $("a.fancybox").fancybox({
             'overlayShow': true,
             'autoSize': false,
             'autoResize': false,
             'autoDimensions': false,
             'enableEscapeButton': true,
             'showCloseButton': true,
             'width': 620,
             'height': 390,
             'type': 'iframe',
             'scrolling': 'no'
         });
     });
    </script>

     <link rel="stylesheet" href="@Url.Content("~/Content/fancybox/jquery.fancybox.css?v=2.1.2")" type="text/css" />
     <script type="text/javascript" src="@Url.Content("~/Content/fancybox/jquery.fancybox.pack.js?v=2.1.2")"></script>
    <link rel="stylesheet" href="@Url.Content("~/Content/fancybox/helpers/jquery.fancybox-buttons.css?v=1.0.5")" type="text/css" />
    <script type="text/javascript" src="@Url.Content("~/Content/fancybox/helpers/jquery.fancybox-buttons.js?v=1.0.5")"></script>
}

But it is showing an error

The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_blanklayout.cshtml": "JavaScript".
4

1 回答 1

2

On the layout page, you need to specify where to render the "JavaScript" section

Somewhere in _blanklayout.cshtml add:

@RenderSection("JavaScript")
于 2013-01-07T21:27:43.473 回答