Hello Max,
As for dumping some text data directly in a specified postion in an ascx
usercontrol, you can consider use the inline rendering expression <%= %>
and call a helper function to output the text in it. For example:
=========ascx template=============
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TextUC.ascx.cs"
Inherits="UserControl_TextUC" %>
<table style="width:100%">
<tr>
<td >
<%= GetLargeText() %>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
==============================
======code behind==============
public partial class UserControl_TextUC : System.Web.UI.UserControl
{
protected string GetLargeText()
{
StreamReader sr = new StreamReader(@"D:\temp\my.log");
string text = Server.HtmlEncode(sr.ReadToEnd());
sr.Close();
return text;
}
}
}
============================
Because such inline render experssion <%= %is called at the whole page's
output rendering, the data returned in the expression will be inserted at
the specfiied position in the page's output content.
As for the response.Write method, it will always write the data into the
Page's response stream directly, at generally before page's Render event,
the page's whole output content has not been flushed yet, so any data write
through "Response.Write" will occur at the top of the page output.
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.