< webopt:BundleReference>将ScriptBundle呈现为css链接元素 [英] <webopt:BundleReference> renders ScriptBundle as css link elements

查看:216
本文介绍了< webopt:BundleReference>将ScriptBundle呈现为css链接元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用新的.net 4.5 webforms控件来渲染我的materpage中的包。我在BundleConfig.cs中定义了一个scriptbundle,如下所示:

I'm trying to use the new .net 4.5 webforms control to render bundles in my materpage. I have a scriptbundle defined in my BundleConfig.cs like this:

bundles.Add(new ScriptBundle("~/bundles/app").Include(
    "~/Scripts/underscore.js",
    "~/Scripts/backbone.js",
    "~/Scripts/app/app.js",
    "~/Scripts/app.validator.js",
    "~/Scripts/app/views/home.js",
    "~/Scripts/app/views/about.js",
    "~/Scripts/app/views/contact.js",
    "~/Scripts/app/controls/hello.js",
    "~/Scripts/app/init.js"));

然后我尝试使用新的< webopt:BundleReference>渲染捆绑包; control:

I then try to render the bundle using the new <webopt:BundleReference> control:

<webopt:BundleReference ID="AppBundle" runat="server" Path="~/bundles/app"  />

但是当页面呈现时,输出为< link> 标签,而不是标签:

But when the page renders, the output is <link> tags, rather than tags:

<link href="/Scripts/underscore.js" rel="stylesheet"/>
<link href="/Scripts/backbone.js" rel="stylesheet"/>
<link href="/Scripts/app/app.js" rel="stylesheet"/>
<link href="/Scripts/app/views/home.js" rel="stylesheet"/>
<link href="/Scripts/app/views/about.js" rel="stylesheet"/>
<link href="/Scripts/app/views/contact.js" rel="stylesheet"/>
<link href="/Scripts/app/controls/hello.js" rel="stylesheet"/>
<link href="/Scripts/app/init.js" rel="stylesheet"/>

此控件是否仅用于渲染样式?或者我做错了什么?如何使用webopt控件而不是<%:Scripts.Render()%> 语法呈现脚本包?

Is this control meant to only render styles? Or am I doing something wrong? How can I render a script bundle using a webopt control and not the <%: Scripts.Render() %> syntax?

推荐答案

我正在使用VS2012和.Net 4.5。我使用webopt控件。我这样呈现:

I'm using VS2012 and .Net 4.5. I do npt use the webopt control. I render like this:

<head>
  <asp:PlaceHolder runat="server">
    <%: Styles.Render("~/Content/MainContentCSS") %>
    <%: Scripts.Render("~/bundles/jqueryPlus") %>
  </asp:PlaceHolder>
</head>

其中我的css和js也在BundleConfig.vb中定义为:

where my css and js are also defined in BundleConfig.vb as:

bundles.Add(New ScriptBundle("~/bundles/jqueryPlus").Include(
            "~/Scripts/modernizr-{version}.js",
            "~/Scripts/jquery-{version}.js",
            "~/Scripts/jquery-ui-{version}.js",
            "~/ig_ui/js/infragistics.js",
            "~/Site.Master.js"))

bundles.Add(New StyleBundle("~/Content/MainContentCSS").Include(
                  "~/Content/Site.css",
                  "~/Content/Site-overrides.min.css",
                  "~/Content/rs-custom-controls.min.css",
                  "~/ig_ui/css/structure/infragistics.css",
                  "~/Examiner/Claim.master.min.css"))

并呈现为:

<link href="/Content/Site.css" rel="stylesheet"/>
<link href="/Content/Site-overrides.min.css" rel="stylesheet"/>
<link href="/Content/rs-custom-controls.min.css" rel="stylesheet"/>
<link href="/ig_ui/css/structure/infragistics.css" rel="stylesheet"/>
<link href="/Examiner/Claim.master.min.css" rel="stylesheet"/>
<script src="/Scripts/jquery-2.1.3.js"></script>
<script src="/Scripts/jquery-ui-1.11.2.js"></script>
<script src="/Scripts/modernizr-2.8.3.js"></script>
<script src="/ig_ui/js/infragistics.js"></script>
<script src="/Site.Master.js"></script>

这篇关于&LT; webopt:BundleReference&GT;将ScriptBundle呈现为css链接元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆