ASP.NET CSS文件路径解析混乱

时间:2014-05-31 11:33:08

标签: c# javascript css asp.net

我是ASP.NET新手。在母版页内,我指定包含cssjavascript文件声明的标头代码,并使用runat=server属性。现在对于javascript文件,我必须在母版页中指定ResolveUrl方法,否则它们将不会被浏览器执行,但CSS文件在没有ResolveUrl方法的情况下可以正常工作。

我认为CSS文件也在客户端执行,并且不理解为什么他们不需要使用ResolveUrl方法。

为什么JavaScript文件需要ResolveUrl方法,但CSS文件不需要?

以下是母版页头代码的摘录:

<head runat="server">

<!-- Basic Page Needs
    ================================================== -->
<meta charset="utf-8">
<title>Home </title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Mobile Specific Metas
    ================================================== -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- CSS
    ================================================== -->
<link rel="stylesheet" href="~/Content/css/skeleton.css" class="responsive">
<link rel="stylesheet" href="~/Content/css/style.css">
<link rel="stylesheet" href="~/Content/css/color/orange.css" class="color">
<link rel="stylesheet" href="~/Content/css/flexslider.css">
<link rel="stylesheet" href="~/Content/css/font-awesome.min.css">
<link rel="stylesheet" href="~/Content/css/colorbox.css">
<link rel="stylesheet" href="~/Content/css/sequence.css">
<!-- Fonts
    ================================================== -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,800' rel='stylesheet' type='text/css'>
<!-- JavaScript
    ================================================== -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/js/flexslider-min.js") %>"> </script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/js/selectnav.min.js")%>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/js/ui.totop.js")%>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/js/easing.1.3.js") %>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/js/jcarousel.min.js") %>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/js/jflickrfeed.min.js") %>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/js/twitter/tweet.min.js") %>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/js/custom.js") %>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/js/sequence-min.js") %>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/js/quicksand.js") %>"></script>
<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/js/colorbox.js") %>"></script>

0 个答案:

没有答案