views:

261

answers:

0

What I have?

I am developing a Web Part where Client Callbacks are used. Each callback updates the page with huge volume of HTML content.

What am I doing?

I am creating a Table control which contains several other controls (around 500KB of static text and light image tags will be in it). I render the table using the below method:

public static string RenderControl(this Control control)
{
    StringBuilder sb = new StringBuilder();
    using (StringWriter sw = new StringWriter(sb))
    {
        using (HtmlTextWriter textWriter = new HtmlTextWriter(sw))
        {
            control.RenderControl(textWriter);
        }
    }
    return sb.ToString();
}

What I need?

Instead of creating a Table and rendering it as string, I can directly use HtmlTextWriter to construct the HTML content.

Will there be a huge difference in the performance of these two methods?

Thanks in advance!