Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

Code Block
languagejava
{newcode:language=csharp}<%@ 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>
Code Block

Useful methods of the CodeTemplateWriter class include:

...