Exemplo n.º 1
0
        public static string RenderControlToHTML(System.Web.UI.UserControl uc)
        {
            string rtv = string.Empty;

            _sb = new StringBuilder();
            TextWriter     _textWriter     = new StringWriter(_sb);
            HtmlTextWriter _htmlTextWriter = new HtmlTextWriter(_textWriter);

            uc.RenderControl(_htmlTextWriter);
            rtv = _htmlTextWriter.ToString();
            return(rtv);
        }
Exemplo n.º 2
0
        public static string RenderControl(this System.Web.UI.UserControl c)
        {
            StringBuilder sb = new StringBuilder();

            using (System.IO.StringWriter sw = new StringWriter(sb))
            {
                using (HtmlTextWriter w = new HtmlTextWriter(sw))
                {
                    c.RenderControl(w);
                }
            }
            return(sb.ToString());
        }
Exemplo n.º 3
0
    public static string RenderToMessage(System.Web.UI.UserControl ctrControl)
    {
        System.Text.StringBuilder    sbuBuilder;
        System.IO.StringWriter       wriWriter;
        System.Web.UI.HtmlTextWriter htwWriter;

        sbuBuilder = new System.Text.StringBuilder();

        sbuBuilder.Append("<html>");
        sbuBuilder.Append("<body>");

        wriWriter = new System.IO.StringWriter(sbuBuilder);
        htwWriter = new System.Web.UI.HtmlTextWriter(wriWriter);
        ctrControl.RenderControl(htwWriter);

        htwWriter.Close();
        wriWriter.Close();

        sbuBuilder.Append("</body>");
        sbuBuilder.Append("</html>");

        return(sbuBuilder.ToString());
    }
Exemplo n.º 4
0
        private string RenderControl(UserControl control)
        {
            StringBuilder sb = new StringBuilder();

            // Render the control into the stringbuilder
            StringWriter sw = new StringWriter( sb );
            Html32TextWriter htw = new Html32TextWriter( sw );
            control.RenderControl( htw );

            // Get full body text
            return sb.ToString();
        }