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. Converting HtmlTextWriter to String or Stream

Converting HtmlTextWriter to String or Stream

Scheduled Pinned Locked Moved ASP.NET
csharptutorialquestion
8 Posts 4 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.
  • L Offline
    L Offline
    Leo Smith
    wrote on last edited by
    #1

    I would like to find out how to convert HtmlTextWriter to either a string or a stream? I am working with an application that requires this to be either in a string or stream format and I can't seem to accomplish this. ToString only gives me the object name. Any assistance would be appreciated. Current language is C# but VB is fine. Thanks,

    Leo T. Smith Senior Programmer/Analyst

    L G L 3 Replies Last reply
    0
    • L Leo Smith

      I would like to find out how to convert HtmlTextWriter to either a string or a stream? I am working with an application that requires this to be either in a string or stream format and I can't seem to accomplish this. ToString only gives me the object name. Any assistance would be appreciated. Current language is C# but VB is fine. Thanks,

      Leo T. Smith Senior Programmer/Analyst

      L Offline
      L Offline
      Leo Smith
      wrote on last edited by
      #2

      I would like to add one thing. All I am trying to get is the whole page response file in a string before I send it to the browser. I really don't want to iterate through all the controls and build the page manually. Thanks, Leo

      Leo T. Smith

      D 1 Reply Last reply
      0
      • L Leo Smith

        I would like to add one thing. All I am trying to get is the whole page response file in a string before I send it to the browser. I really don't want to iterate through all the controls and build the page manually. Thanks, Leo

        Leo T. Smith

        D Offline
        D Offline
        Dominic Pettifer
        wrote on last edited by
        #3

        Are you trying to get the full raw HTML response for the entire page or for just a control?

        Dominic Pettifer Blog: www.dominicpettifer.co.uk

        L 1 Reply Last reply
        0
        • L Leo Smith

          I would like to find out how to convert HtmlTextWriter to either a string or a stream? I am working with an application that requires this to be either in a string or stream format and I can't seem to accomplish this. ToString only gives me the object name. Any assistance would be appreciated. Current language is C# but VB is fine. Thanks,

          Leo T. Smith Senior Programmer/Analyst

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Create a StringWriter and create the HtmlTextWriter using that. The ToString method of the StringWriter returns what's written to the HtmlTextWriter as a string.

          Experience is the sum of all the mistakes you have done.

          L 1 Reply Last reply
          0
          • D Dominic Pettifer

            Are you trying to get the full raw HTML response for the entire page or for just a control?

            Dominic Pettifer Blog: www.dominicpettifer.co.uk

            L Offline
            L Offline
            Leo Smith
            wrote on last edited by
            #5

            Yes I want the complete raw html, like you would see in a text editor, or by going view source. Thanks,

            Leo T. Smith

            1 Reply Last reply
            0
            • G Guffa

              Create a StringWriter and create the HtmlTextWriter using that. The ToString method of the StringWriter returns what's written to the HtmlTextWriter as a string.

              Experience is the sum of all the mistakes you have done.

              L Offline
              L Offline
              Leo Smith
              wrote on last edited by
              #6

              Is there a function call to convert a current HtmlTextWriter to a StringWriter before using the ToString function in the StringWriter? Thanks,

              Leo T. Smith

              G 1 Reply Last reply
              0
              • L Leo Smith

                Is there a function call to convert a current HtmlTextWriter to a StringWriter before using the ToString function in the StringWriter? Thanks,

                Leo T. Smith

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #7

                Cast the InnerWriter property to StringWriter (assuming of course that the HtmlTextWriter is actually based on a StringWriter).

                Experience is the sum of all the mistakes you have done.

                1 Reply Last reply
                0
                • L Leo Smith

                  I would like to find out how to convert HtmlTextWriter to either a string or a stream? I am working with an application that requires this to be either in a string or stream format and I can't seem to accomplish this. ToString only gives me the object name. Any assistance would be appreciated. Current language is C# but VB is fine. Thanks,

                  Leo T. Smith Senior Programmer/Analyst

                  L Offline
                  L Offline
                  logiclabz
                  wrote on last edited by
                  #8

                  This link was useful to me Convert HtmlTextWriter to String in C#

                  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