我在一个网页上有一些UserControls。当我在我的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中出现呢?
我将使用Literal
控件。