Just Code‎ > ‎

C# Asp.Net - See html output before sending it to the client

posted Feb 14, 2010, 3:46 AM by Peter Henell

protected override void Render(HtmlTextWriter writer)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        HtmlTextWriter tw = new HtmlTextWriter(new
        System.IO.StringWriter(sb));
        //Render the page to the new HtmlTextWriter which actually writes to the stringbuilder
        base.Render(tw);

        //Get the rendered content
        string sContent = sb.ToString();

        //Now output it to the page, if you want
        writer.Write(sContent);
    }
Comments