【发布时间】:2011-01-21 08:05:55
【问题描述】:
所以..这是我在 MVC2 项目中的 site.master ASPX 文件的上半部分:
<head runat="server">
<link href="<%= ViewData[SomeNamespace.StyleSheetKey]; %>" rel="stylesheet" type="text/css" />
</head>
<div foo="<%= (string) ViewData[SomeNamespace.StyleSheetKey] %>">bar</div>
现在 div 标签正确地呈现了样式表名称,但链接标签中的那个在它被写入时被呈现,没有被解释。另外添加了一个路径前缀。
所以 ASP.NET 引擎似乎想处理链接标记中 href- 参数中的文本,“帮助”我为我的 .css 文件添加正确的相对路径前缀。
我现在如何能够以编程方式设置样式表的名称?
【问题讨论】:
-
我现在这是一个很长的镜头,但请尝试从 中删除 runat="server" 标记
-
您先生,是赢家 :-) 将其发布为答案,而不是评论!
标签: css asp.net-mvc master-pages