1

我有一个具有菜单功能的基于母版页的网站。成功从 Style.css 文件中读取 CSS。我现在添加了一个单独的 Login.aspx 页面,该页面功能正常,但没有选择具有登录页面特定 css 的 Account.css 文件。我不希望登录页面引用母版页。

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"      type="text/javascript"></script>
    <link href="Account.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(document).ready(function () {
                 $('.grid_12').fadeIn(1750);
        });
    </script>
</head>

我将不胜感激,因为我尝试过以我能想到的各种方式引用 Account.css 文件路径:

href="./Account.css"
href="Account.css"
href="~/Account.css"

我现在已将 Login.aspx 页面和 Account.css 文件放在网站根目录的新登录文件夹中。

4

2 回答 2

1

您可能正在使用表单身份验证的区域。
如果是,那么您可以使用

 <location path="Account.css">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>

里面

<appSettings></appSettings>

否则你可以使用

<style type="text/css" src='<%= ResolveUrl("Account.css")%>'></script>
于 2012-11-09T10:17:04.763 回答
0

似乎您在 IIS 上的虚拟目录中托管您的站点。如果你这样做,你的路径必须反映虚拟目录。

href="/virtualDir/Account.css"

要做到这一点是 asp.net 使用ResolveClientUrl

href="<%= ResolveClientUrl("~/Account.css") %>"
于 2012-11-09T10:24:07.130 回答