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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Replace cr/nl with html break tag

Replace cr/nl with html break tag

Scheduled Pinned Locked Moved ASP.NET
csharpquestionhtmlasp-networkspace
4 Posts 3 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.
  • J Offline
    J Offline
    jc net
    wrote on last edited by
    #1

    Hi I have a normal string-variable in asp.net/c#, that contains cr/nl characters that I want to replace with
    tags. When viewing the string in debugmode in VS2005, I can see them in there as "\r\n". I have tried replacing with: str.Replace("\r\n","
    "); str.Replace(Environment.Newline,"
    "); but it does not work. How can I do that? Wonder if its something about UniCode-characters. Thanks.

    C J 2 Replies Last reply
    0
    • J jc net

      Hi I have a normal string-variable in asp.net/c#, that contains cr/nl characters that I want to replace with
      tags. When viewing the string in debugmode in VS2005, I can see them in there as "\r\n". I have tried replacing with: str.Replace("\r\n","
      "); str.Replace(Environment.Newline,"
      "); but it does not work. How can I do that? Wonder if its something about UniCode-characters. Thanks.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      This should work fine. You should put a closing tag in your breaks, so they are XHTML. What happens when you try this ?

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      J 1 Reply Last reply
      0
      • C Christian Graus

        This should work fine. You should put a closing tag in your breaks, so they are XHTML. What happens when you try this ?

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        J Offline
        J Offline
        jc net
        wrote on last edited by
        #3

        yes, but it does not, wonder if its something about UniCode-characters

        1 Reply Last reply
        0
        • J jc net

          Hi I have a normal string-variable in asp.net/c#, that contains cr/nl characters that I want to replace with
          tags. When viewing the string in debugmode in VS2005, I can see them in there as "\r\n". I have tried replacing with: str.Replace("\r\n","
          "); str.Replace(Environment.Newline,"
          "); but it does not work. How can I do that? Wonder if its something about UniCode-characters. Thanks.

          J Offline
          J Offline
          Jon Sagara
          wrote on last edited by
          #4

          Are you just calling them like this? str.Replace("\r\n","<br>"); str.Replace(Environment.Newline,"<br>"); Or are you actually assigning the value back to str? str = str.Replace("\r\n","<br>"); str = str.Replace(Environment.Newline,"<br>");

          Jon Sagara Mike3285: wtf is a palindrome MaroonSand: no its not dude -- Bash.org Personal Blog | .NET Blog | Articles

          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