Results 1 to 2 of 2

Thread: Render Table Control to HTML

  1. #1

    Thread Starter
    Hyperactive Member tailz's Avatar
    Join Date
    Jul 2002
    Posts
    306

    Render Table Control to HTML

    I have a table object and I want to render it as html into a string. I've been looking at htmltextwriters etc but a touch confused.

    Any help appreicated :]

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: Render Table Control to HTML

    You want put the output of your control's render method into a string ? Normally, you just use RenderContents(htmlwriter).

    But this should get you started:
    Code:
    System.IO.MemoryStream stream = new System.IO.MemoryStream();
    			System.IO.TextWriter t = new System.IO.StreamWriter(stream);
    			System.Web.UI.HtmlTextWriter h = new System.Web.UI.HtmlTextWriter(t);
    			System.Web.UI.WebControls.Table table = new Table();
    			table.Height = 200;
    			table.RenderControl(h);
    			h.InnerWriter.Flush();
    			byte[] r = new byte[stream.Length];
    			stream.Seek(0,System.IO.SeekOrigin.Begin);
    			stream.Read(r,0,r.Length);
    			result = System.Text.Encoding.ASCII.GetString(r,0,r.Length);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width