【发布时间】:2010-08-10 21:25:00
【问题描述】:
假设我在标准 ASP.NET 2.0 Web 表单中有以下标记:
<head runat="server">
<title>My Snazzy Page</title>
<link type="text/css" href="<%= PathUtilities.AssetPath %>/css/page.css" rel="stylesheet" />
<script type="text/javascript" src="<%=PathUtilities.AssetPath %>/lib/jquery/1.4.2/jquery.min.js"></script>
</head>
奇怪的是,这会在字面上呈现 <link> 元素,并带有嵌入的代码括号,同时它将相同代码的输出插入到脚本标记中。换句话说,浏览器会看到:
<head><title>My Snazzy Page
</title><link type="text/css" href="<%= PathUtilities.AssetPath %>/css/page.css" rel="stylesheet" />
<script type="text/javascript" src="/rmt/lib/jquery/1.4.2/jquery.min.js"></script>
</head>
如果我从 head 元素中删除 runat="server",显然问题就会消失。
【问题讨论】: