示例#1
0
        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());
        }
示例#2
0
    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);
    }
示例#3
0
 public void closeFiles()
 {
     // close the files
     _doc.Close();
     _sw.Close();
 }