问题描述:
在ASP.NET的WebForm里面,如果头部用数据绑定<%%>,页面输出的结果往往不是我们想要的,比如像下面这样:
<link rel="Stylesheet" type="text/css" href='<%=Config.ResourcesDomain %>/images/style.css' />
能够正常生产和运行,但是生成的内容却是:
<link rel="Stylesheet" type="text/css" href="<%=Config.ResourcesDomain %>/images/style.css" />
解决办法:
改种写法:
href=<%= Config.ResourcesDomain %>/images/style.css
或者:
href="<%= "" + Config.ResourcesDomain %>/images/style.css"
或者:
<head runat="server">
<%
Response.Write("<link rel='Stylesheet' type='text/css' href='" + Config.ResourcesDomain + "/images/style.css' />");
%>
<title></title>
</head>
参考: <http://stackoverflow.com/questions/8104268/inline-code-in-head-tag-asp-net>
时间: 2024-11-03 22:18:33