Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Getting HTML from Control.Render

Getting HTML from Control.Render

Scheduled Pinned Locked Moved ASP.NET
htmltutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dan Morris
    wrote on last edited by
    #1

    I can get a Control to Render its HTML output to an HtmlTextWriter, but I am unable to get the HtemlTextWriter to give me the HTML string that it contains. Nor can I figure out from the documentation how to access the output stream object the writer references so that I can get the HTML from the original control. Any ideas? Thanks in advance. Dan Morris

    A 1 Reply Last reply
    0
    • D Dan Morris

      I can get a Control to Render its HTML output to an HtmlTextWriter, but I am unable to get the HtemlTextWriter to give me the HTML string that it contains. Nor can I figure out from the documentation how to access the output stream object the writer references so that I can get the HTML from the original control. Any ideas? Thanks in advance. Dan Morris

      A Offline
      A Offline
      Alvaro Mendez
      wrote on last edited by
      #2

      Here's one way:

      HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());
      control.RenderControl(writer);

      string html = writer.InnerWriter.ToString();

      Regards, Alvaro


      You know what they say about arguing over the Internet...

      D 2 Replies Last reply
      0
      • A Alvaro Mendez

        Here's one way:

        HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());
        control.RenderControl(writer);

        string html = writer.InnerWriter.ToString();

        Regards, Alvaro


        You know what they say about arguing over the Internet...

        D Offline
        D Offline
        Dan Morris
        wrote on last edited by
        #3

        Thanks. I'll give it a try. Dan Morris

        1 Reply Last reply
        0
        • A Alvaro Mendez

          Here's one way:

          HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());
          control.RenderControl(writer);

          string html = writer.InnerWriter.ToString();

          Regards, Alvaro


          You know what they say about arguing over the Internet...

          D Offline
          D Offline
          Dan Morris
          wrote on last edited by
          #4

          That worked. Thanks! Dan Morris

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups