Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# CSS样式表不显示效果_C#_Asp.net_Css - Fatal编程技术网

C# CSS样式表不显示效果

C# CSS样式表不显示效果,c#,asp.net,css,C#,Asp.net,Css,我使用的是Asp.Net/C。目前我正在登录页面上工作,我的登录页面不依赖于母版页,因此我在标题部分设置了指向样式表的链接 <link rel="stylesheet" href="Styles/Login.css" type="text/css"/> 这是登录页面 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HomeLogin.aspx.cs" Inherits="CwizBankApp.HomeLo

我使用的是
Asp.Net/C
。目前我正在登录页面上工作,我的
登录页面
不依赖于
母版页
,因此我在标题部分设置了指向
样式表
的链接

<link  rel="stylesheet" href="Styles/Login.css" type="text/css"/>
这是登录页面

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HomeLogin.aspx.cs" Inherits="CwizBankApp.HomeLogin" %>

<!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>Comwizard Systems | Login</title>
    <link  rel="stylesheet" href="Styles/Login.css" type="text/css"/>

</head>
<body>
    <form id="form1" runat="server">

    <div id="loginbox">
    <span>UserName:</span><asp:TextBox ID="txtUserName" runat="server"></asp:TextBox> <br /> 
    <span style="margin-left:6px;">Password:</span><asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox><br />  
    <asp:Button ID="cmdLogin"  runat="server" Text="Login" onclick="cmdLogin_Click" />

    </div>
    </form>
</body>
</html>

Comwizard系统|登录
用户名:
密码:
有人能帮我吗。 非常感谢您的任何建议。 谢谢

问题终于解决了 将此添加到web.config解决了此问题

<location path="~/Styles">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>

快速问题,请检查css文件是否已实际解决

如果您使用的是chorme,那么可以使用开发人员工具和网络部分查看所有通过的请求

如果您使用的是firefox,请使用firebug

感谢

查看源代码(如果使用chrome/firefox,通常按CTRL+U)并找到其中的
href=“Styles/Login.css”
,您应该能够单击它作为样式表的链接。您应该首先确保您确实正确地链接到它,它加载正确吗?

试试看

href="@Url.Content("~/Styles/Login.css")"
而不是

href="Styles/Login.css"

如果您使用的是Visual Studio,intellisense(自动完成)将支持您查找确切位置。打开Url.Content()方法的括号后,只需按Ctrl+Space。

我检查了您的示例,没有任何问题。控件“loginbox”不支持css样式。请检查您的css文件是否位于正确的位置

href="Styles/Login.css"
试试这个

   <location path="~/stylesheets">
        <system.web>
            <authorization>
                <allow users="*" />
            </authorization>
        </system.web>
   </location>


1。检查css文件是否已加载,因为href=“Styles/Login.css”指示文件的相对路径。2.使用调试工具检查dom页面上是否有loginbox div哪个浏览器?我试图用你的代码创建一个示例,它对我很有用。您遇到了什么问题,如颜色不显示、位置不正确等。。。。请详细说明。@AYK…同意你的意见…代码对我也有效,可能是因为CHRIS LEE提到的问题。@AYK我在Chrome、Safari、Firefox中试用过,也是一样,没有应用任何样式。如果我使用内联样式,效果会很好。@freebird…清除浏览器缓存,然后再次运行网站。.它位于正确的文件夹样式中,但不知道是什么原因导致了问题设置页面背景色,并验证您是否正在进行更改。我在chrome中使用了该样式,这是登录请求的结果。css说“接受“。我的问题似乎是表单身份验证,当我将其更改为windows身份验证时,它工作正常,您可能提供的任何解决方法。感谢感谢它的帮助,我最后一个问题是,当使用.js文件时,我必须再次重复它,对吗?我可以创建一个单独的web.config文件并将其放置在适当的文件夹中。感谢您的帮助我问,如果我使用.js文件,我还必须为其设置权限对吗?是的,您必须。。或您可以将.js或CSS文件放在非只读或没有任何权限的文件夹中。。。
   <location path="~/stylesheets">
        <system.web>
            <authorization>
                <allow users="*" />
            </authorization>
        </system.web>
   </location>