我有一个基于母版页的网站,该网站具有菜单功能。成功从 Style.css 文件中读取 CSS。我现在添加了一个单独的 Login.aspx 页面,它运行良好,但没有获取 Account.css 文件,该文件具有登录页面的特定 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 文件放在网站根目录下的新登录文件夹中。
最佳答案
您可能有一个区域正在使用表单例份验证。
如果是那么你可以使用
<location path="Account.css">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
内部
<appSettings></appSettings>
否则你可以使用
<style type="text/css" src='<%= ResolveUrl("Account.css")%>'></script>
关于c# - CSS 在设计 View 中显示而不是在运行时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13306013/