mvc中Scripts.Render的用法

news/2024/7/7 19:55:27


一、配置BundleConfig.cs文件


1、首先要在App_Start 里面BundleConfig.cs 文件里面 添加要包含的css文件

2、BundleConfig就是一个微软新加的 一个打包的配置类

3、BundleConfig用来Add 各种Bundle

4、BundleConfig配置信息如下:


public class BundleConfig {
      public static void RegisterBundles(BundleCollection bundles) {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));
            bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include("~/Scripts/jquery-ui-{version}.js"));
            
            bundles.Add(new StyleBundle("~/Content1/css").Include("~/Content/site.css"));
            bundles.Add(new StyleBundle("~/Content1/themes/base/css").Include(
                        "~/Content/themes/base/jquery.ui.core.css",
                        "~/Content/themes/base/jquery.ui.resizable.css",
                        "~/Content/themes/base/jquery.ui.selectable.css",
                        "~/Content/themes/base/jquery.ui.accordion.css",
                        "~/Content/themes/base/jquery.ui.autocomplete.css",
                        "~/Content/themes/base/jquery.ui.theme.css"));
        }
    }




二、使用Scripts.Render、Styles.Render引用BundleConfig中的配置



1、在视图文件中使用Scripts.Render()输出脚本包,Styles.Render()输出样式包


2、Script文件引用:@Scripts.Render(virtualPath[,virtualPath1][,virtualPath2][,...])


3、CSS文件引用:  @Styles.Render(virtualPath[,virtualPath1][,virtualPath2][,...])


4、实例


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    @Styles.Render("~/Content1/css")
</head>
<body>
    @RenderBody()

    @Scripts.Render("~/bundles/jqueryui")
</body>
</html>

 


文章转载自:mvc中Scripts.Render的用法  http://www.studyofnet.com/news/1178.html




http://www.niftyadmin.cn/n/2610693.html

相关文章

《读完忍不住流泪的文章:母亲,我怎么让妳等了那么久...》

母亲&#xff0c;我怎么让妳等了那么久...文/ 刘继荣 2009/06/03 10:08 母亲真的老了&#xff0c;变得孩子般缠人&#xff0c;每次打电话来&#xff0c;总是满怀热诚地问&#xff1a;「你什么时候回家&#xff1f;」 且不说相隔一千多里路&#xff0c;要转三次车。光是工作、…

JVM类加载的那些事

原文出处&#xff1a; 占小狼 前言 Java源代码被编译成class字节码&#xff0c;最终需要加载到虚拟机中才能运行。整个生命周期包括&#xff1a;加载、验证、准备、解析、初始化、使用和卸载7个阶段。 加载 1、通过一个类的全限定名获取描述此类的二进制字节流&#xff1b;2、将…

mvc razor模式 输出html

&#xfeff;&#xfeff;1、使用Html.Raw(str) Html.Raw("<div stylecolor:red>输出字符串</div>") 2、使用new HtmlString IHtmlString content new HtmlString("<div stylecolor:red>输出字符串</div>");content; 3、直接输出…

js如何获取上个月第一天和最后一天

var nowdays new Date();var year nowdays.getFullYear();var month nowdays.getMonth();if(month0){month12;yearyear-1;}if (month < 10) {month "0" month;}var firstDay year "-" month "-" "01";//上个月的第一天va…

卡尔曼滤波器代码python_基于Python的扩展的卡尔曼滤波器实现的恒定转速和加速度(CTRA)车辆模型...

Extended Kalman Filter Implementation for Constant Turn Rate and Acceleration(CTRA) Vehicle Model in Python.扩展卡尔曼滤波算法扩展的卡尔曼滤波器&#xff0c;其状态转移和观察模型不需要一定是状态的线性函数&#xff0c;而是状态的可微函数&#xff1b;这里&#xf…

jmeter结合autoit操作windows程序

需求&#xff1a; 模拟操作下图软件的控件&#xff0c;如拨号和挂机。 1. 下载安装好autoit后&#xff0c;打开finder tool&#xff0c;使用查找工具定位到要模拟操作的控件上&#xff0c;如图&#xff1a; 2.在finder tool中的control选项卡&#xff0c;可以看到该控件的信息。…

MySql 中IFNULL、ISNULL和NULLIF的区别

&#xfeff;&#xfeff;一、ISNULL(expr) 如果expr 为NULL&#xff0c;那么ISNULL() 的返回值为 1&#xff0c;否则返回值为 0。 例如 ->select isnull(11);->0;->select isnull(null);->1;二、IFNULL(expr1,expr2) 1、若expr1不为null&#xff0c;则ifnull()的…

C#中如何获取上个月第一天和最后一天

&#xfeff;&#xfeff;一、获取上个月第一天 private DateTime FirstDayOfPreviousMonth(DateTime datetime) {return datetime.AddDays(1 - datetime.Day).AddMonths(-1); } 二、获取上个月的最后一天 private DateTime LastDayOfPrdviousMonth(DateTime datetime) {return…