...
Code Block | ||
---|---|---|
| ||
<%@ CodeTemplate Language="C#" TargetLanguage="Text" Description="AddTextWriter Demonstration." %> <%@ Import Namespace="System.IO" %> //This template demonstrates using the AddTextWriter method //to output the template results to multiple locations concurrently. <script runat="template"> public override void Render(TextWriter writer) { StreamWriter fileWriter1 = new StreamWriter(@"C:\test1.txt", true); this.Response.AddTextWriter(fileWriter1); StreamWriter fileWriter2 = new StreamWriter(@"C:\test2.txt", true); this.Response.AddTextWriter(fileWriter2); base.Render(writer); fileWriter1.Close(); fileWriter2.Close(); } </script> |
Note |
---|
Don't omit the call to the base.Render method. If you forget this, then you won't get the default output! |
...