I have some UserControls in a webpage. When I use it in the ASPX code of m开发者_如何学JAVAy UserControl
as such <div><% Page.Response.Write("<a href='http://www.microsoft.com'>test</a>") %></div>
, my anchor is rendered at the start of the page:
<a href='http://www.microsoft.com'>test</a><html><head>
instead of the expected:
<html><head /><body>
<a href='http://www.microsoft.com'>test</a></body></html>
But if i use <div><%="<a href='http://www.microsoft.com'>test</a>" %></div>
then the response is written inline as expected.
We used this technique of Page.Response.Write()
a lot in .NET 3.5, and now migrating to .NET 4.0, we are experiencing this problem with it. Why does it happen in .NET 4.0?
I would move to using the Literal
control.
精彩评论