C# ASPX / ASCX Control render dynamically to string

Date: 2016-07-04
using System;
using System.Web;
using System.Web.UI;
using System.Text;
using System.IO;

System.Web.UI.Page page = new System.Web.UI.Page();						
StringBuilder output = new StringBuilder();
TextWriter textWriter = new StringWriter(output);
HtmlTextWriter htmlWriter = new HtmlTextWriter(textWriter);
Control control = page.LoadControl("~/Controls/DataTransformation.ascx");					
control.RenderControl(htmlWriter);	
2480cookie-checkC# ASPX / ASCX Control render dynamically to string