Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.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
Asp.net 仅在visual studio designer中使用CSS_Asp.net_Css - Fatal编程技术网

Asp.net 仅在visual studio designer中使用CSS

Asp.net 仅在visual studio designer中使用CSS,asp.net,css,Asp.net,Css,我正在VisualStudio2008中开发一个Web应用程序。出于某种原因,CSS只能在VisualStudio中正常工作。我可以在页面的设计视图中看到CSS。当我在localhost上查看页面时,没有应用CSS。这只是我正在使用的一个非常简单的示例。只有2页,一个母版页和一个默认页 这是母版页 <head runat="server"> <title>Foobar My Title</title> <asp:ContentPlaceHol

我正在VisualStudio2008中开发一个Web应用程序。出于某种原因,CSS只能在VisualStudio中正常工作。我可以在页面的设计视图中看到CSS。当我在localhost上查看页面时,没有应用CSS。这只是我正在使用的一个非常简单的示例。只有2页,一个母版页和一个默认页

这是母版页

<head runat="server">
<title>Foobar My Title</title>      
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<link id="stylemain" href="Content/Style/main.css" rel="stylesheet" type="text/css"/> 
</head>
<body>

<form id="form1" runat="server">
<table border="1">
    <tr>          
    <td><a href="Default.aspx" class="topContent">Foobar</a></td>
    </tr>
    <tr>
    </tr>
    <tr>
    <td>test</td>        
    </tr>
</table>  
</form>
</body>
</html>

}您的CSS可能位于错误的相对路径。要修复此问题,请将链接更改为应用程序相对样式,如下所示:

<link id="stylemain" href="~/Content/Style/main.css" rel="stylesheet" type="text/css"/> 


母版页将正确解决此问题,在这种情况下无需运行
runat=“server”

问题在于IIS7我在设置静态内容时没有检查它。

您最近更改了CSS文件吗?浏览器缓存中可能有旧版本的CSS文件。清除浏览器缓存,看看这是否解决了问题

<link id="stylemain" href="~/Content/Style/main.css" rel="stylesheet" type="text/css"/>