Why does calling page.RenderControl not evaulate <% Response.Write("foo") %>
but it does evaluate <%= "bar" %>
? Is there something else I should be calling instead?
I was under the impression that <%= %>
was shorthand for Response.Write
as it is in classic ASP.
... <p><%= "foo" %&g开发者_如何学Got;<% Response.Write("bar"); %></p> ...
Render Control code...
string output;
using (var mem = new StringWriter())
using (var writer = new XhtmlTextWriter(mem))
{
page.RenderControl(writer);
output = mem.GetStringBuilder().ToString();
}
Outputs...
Expected: "<p>foobar</p>"
Actual: "<p>foo</p>"
<%= %> is the same as Response.Write in asp.net. Thats why <%= "bar" %> works.
You are missing a semicolon at the end of <% Response.Write("bar") %> . Thats why it is not working.
I have the same problem with yours, my solution is just use <%=...%>
instead of response.write();
Personally think the reason looks like former render earlier than response.write()
. Once program reach response.write()
function the RenderControl
object has no control over it even if in server-side tag.
精彩评论