protected static string RenderControl(Control control) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.IO.StringWriter sw = new System.IO.StringWriter(sb); System.Web.UI.Html32TextWriter htmlWriter = new Html32TextWriter(sw); control.RenderControl(htmlWriter); htmlWriter.Close(); sw.Close(); return(sb.ToString()); }
public Stream GetContent(string cType) { var tw = new StringWriter(); var writer = new Html32TextWriter(tw); var page = new Page(); var control = page.LoadControl(cType); control.RenderControl(writer); writer.Close(); var stream = new MemoryStream(Encoding.UTF8.GetBytes(tw.ToString())); WebOperationContext.Current.OutgoingResponse.ContentType = "text/html"; WebOperationContext.Current.OutgoingResponse.Headers.Add("Cache-Control", "no-cache"); return(stream); }
public void closeFiles() { // close the files _doc.Close(); _sw.Close(); }