1

我在网页中有一些用户控件。当我在我的 UserControl 的 ASPX 代码中使用它时<div><% Page.Response.Write("<a href='http://www.microsoft.com'>test</a>") %></div>,我的锚点呈现在页面的开头:

<a href='http://www.microsoft.com'>test</a><html><head>

而不是预期的:

<html><head /><body>
<a href='http://www.microsoft.com'>test</a></body></html>

但是,如果我使用<div><%="<a href='http://www.microsoft.com'>test</a>" %></div>,那么响应将按预期内联写入。

我们在 .NET 3.5 中大量使用了这种技术Page.Response.Write(),现在迁移到 .NET 4.0,我们遇到了这个问题。为什么会发生在 .NET 4.0 中?

4

1 回答 1

2

我会转向使用Literal控件。

于 2011-09-29T13:21:37.587 回答