protected override void Render (HtmlTextWriter writer) { // *** Write the HTML into this string builder StringBuilder sb = new StringBuilder(); HtmlTextWriter hWriter = new HtmlTextWriter(new StringWriter(sb)); base.Render(hWriter); // *** store to a string string PageResult = sb.ToString(); // *** Write it back to the server writer.Write(PageResult); // *** Now strip out confirmation part string Confirmation = wwUtils.StrExtract(PageResult,"<!-- Start Confirmation Display --->", "<!-- End Confirmation Display --->"); if (wwUtils.Empty(Confirmation)) return; // *** Turn this text into an HTML document and add // *** headers and style sheet Confirmation = Confirmation.Replace("Your Order Confirmation","West Wind Technologies Order Confirmation"); // *** TODO: Add Style Sheet sb = new StringBuilder(); sb.Append("<html><body>"); sb.Append(Confirmation); sb.Append(" </body></html>"); this.SendConfirmationEmail(sb.ToString()); }This is definitely cool though - because I have a number of pages where part of the page gets generated needs to be reused for multiple purposes. Doing this any other way would be way more complicated since .Net doesn't easily support some sort of mail merge (well it does by using the ASP.Net runtime which would incur a fair amount of overhead).
>protected override void Render (HtmlTextWriter writer) >{ > StringBuilder stringBuilder = new StringBuilder(); > StringWriter stringWriter = new StringWriter(stringBuilder); > HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter); > base.Render(htmlWriter); > string yourHtml = stringBuilder.ToString(); > // yourHtml string contains the HTML generated >} >>