zoukankan      html  css  js  c++  java
  • MVC3.0入门学习笔记Razor 之样式加载方式1

    项目下添加App_Code 文件夹(手动添加重命名)

    添加 Style.cshtml

    基于 helper类 写通用方法

    @using System.Web.Mvc;
    @using WebMatrix.Data;//这个要手动拷贝到bin目录下 不知道为什么添加引用后不自动过去
    @helper Script(string scriptName, UrlHelper Url) { <script src="@Url.Content(scriptName)" type="text/javascript"></script> } @helper Css(string cssName, UrlHelper Url) { <link href="@Url.Content(cssName)" rel="stylesheet" type="text/css" /> }

     然后其他.cshtml调用方法

    @Style.Css("/offerstyle/css/offer-manage.css", this.Url)

    @Style.Script("/script/formValidator.js", this.Url)

    这样就不用每次都写

    <script src="@Url.Content("xxxxxx")" type="text/javascript"></script>了
  • 相关阅读:
    Hadoop组件
    Vmworkstation启用错误
    sqoop
    ZooKeeper02
    动物管理员--zooKeeper-01
    IP-v4&IP-v6
    hive 基础
    ssh连接失败,排错经验
    Hadoop管理员的十个最佳实践
    OSGi在淘宝内部的使用
  • 原文地址:https://www.cnblogs.com/jcgh/p/2385389.html
Copyright © 2011-2022 走看看