2012-04-09 96 views
0

我使用Asp.Net/C#。目前,我的工作在登录页面上,我login page是不依赖于Master Page,因此链接到Stylesheet我的头段已设置CSS样式表不显示效果

<link rel="stylesheet" href="Styles/Login.css" type="text/css"/> 

的问题是,样式没有在我的登录控件任何efeect page.Here是我的CSS文件

body 
{ 
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 
    font-size:75%; 
} 
#loginbox 
{ 
    position:fixed; 
    background-color:#9cc3f7; 
    border:2px solid #ddd; 
    height:200px; 
    width:300px; 
    top:50%; 
    margin-left: -130px; 
    margin-top: -100px; 
    left:50%; 
} 

这里是登录页面

<%@ 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> 

任何人可以帮助我。 任何建议都高度赞赏。 感谢

最后这个问题已经解决了 在web.config中添加此解决它

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

1.检查CSS文件是否是负载因为HREF =“样式/ Login.css”表示该文件的相对路径。 2。使用调试工具来检查你的dom页面上是否有登录框div – 2012-04-09 06:20:30

+0

哪个浏览器?我试图从你的代码中创建一个示例,它适用于我。你跑了什么问题,如颜色不显示,位置不正确等...请详细说明。 – AYK 2012-04-09 06:21:29

+0

@AYK ....同意你...代码对我也有效,可能是问题是由于CHRIS LEE提到的问题... – Usman 2012-04-09 06:23:46

回答

2

试试这个

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

请更新您的样式表路径的路径....请参阅本文

http://forums.asp.net/t/1678658.aspx/1

+0

我的问题似乎是窗体身份验证,当我将其更改为Windows身份验证,它可以正常工作,您可能能够提供任何解决方法。感谢 – freebird 2012-04-09 06:52:51

+0

非常感谢它帮助,我最后一个问题是使用.js文件时,我会不得不再次重复它,我可以创建一个单独的web.config文件,并将其放在适当的folders.Thanks你的帮助 – freebird 2012-04-09 07:38:12

+0

我很抱歉,我不能让你..请稍微解释我.. – Usman 2012-04-09 07:57:56

0

快速的问题,你可以请检查CSS文件实际上是否解决?

如果你正在使用chorme,您可以使用开发工具和使用网络部分,看到所有经过的请求。

如果您使用的是Firefox,使用Firebug的相同。

感谢

+0

我在chrome中使用它,它向Login.css的请求显示“接收”。 – freebird 2012-04-09 06:37:04

0

查看源代码(通常按CTRL + ü如果使用Chrome/Firefox浏览器),并找到它说:href="Styles/Login.css",你应该能够点击,作为一个链接到你的样式表。你应该确保你确实首先正确地链接到它,它是否正确加载?

0

尝试

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

,而不是

href="Styles/Login.css" 

如果您正在使用Visual Studio,智能感知(自动完成)会支持你找到确切的位置。在打开Url.Content()方法的括号后,只需按Ctrl + Space即可。

0

我检查你的样本,并在所有没有问题。控制“登录框”确实获得CSS样式。请检查你的css文件是否在正确的位置。

href="Styles/Login.css" 
+0

它是在正确的文件夹样式,但不知道什么可能导致问题 – freebird 2012-04-09 06:35:21

+0

设置页面的背景颜色,并验证您是否正在获取更改。 – 2012-04-09 06:37:19