Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Current »

The Response property of the CodeTemplate object returns an instance of the CodeTemplateWriter class. This object represents the actual response stream for the template output. You can write to the stream programmatically using this property, thus inserting your own output directly into the generated template. For example:

<%@ CodeTemplate Language="C#" TargetLanguage="Text" Description="This template demonstrates writing directly to the Response property" %>
<% RenderDirect(); %>
<script runat="template">
public void RenderDirect()
{
Response.WriteLine("Written directly to the Response property.");
Response.WriteLine("Hello " + System.Environment.UserName + "!");
}
</script>

Useful methods of the CodeTemplateWriter class include:

  • AddTextWriter - Add an additional output destination
  • Indent - Increase the indentation level of the output
  • Unindent - Decrease the indentation level of the output
  • Write - Write to the generated template without appending a new line
  • WriteLine - Write to the generated template and append a new line
  • No labels