Need help with Environment.NewLine issue RRS feed

  • Question

  • User1357722171 posted


    I'm new to all of this and my english is not perfect so I hope I can get myself clear.

     What I've got is something quite weird. I have several pages with some data input controls (mostly textboxes with the MultiLine option) with an InsertButtonClick function that stores the data in the database as string.

    Now, in other pages, this data is shown as ReadOnly and I'm using the

                Label01.Text = Label01.Text.Replace(Environment.NewLine, "<br />")

     so the linebreaks are shown. And it works...  In some pages... But not in all of them.

    I'm doing the exact same stuff but the Replace NewLine thing doesn't seem to work in every page. I've tried using ...Replace("[whatever character that is in the text]", "<br />") and it does the linebreaks. The linebreaks exists in the html (seen in soucecode of the browser) but is not replaced with the <br/>. But again, it worked in some pages. I practically copy/pasted the page. I went to the "Show Table Data" and it the data is stored with breaks...

    I'm quite desperate with this issue so any help will be appreciated .







    Monday, July 28, 2008 7:22 AM

All replies

  • User1710623990 posted

    Try something like this:

    Label01.Text = Label01.Text.Replace(Environment.NewLine, "<br/>").Replace("\n", "<br/>").Replace("\r", "<br/>"); 
    Hope that helps [Yes] 
    Monday, July 28, 2008 7:40 AM
  • User1357722171 posted

     Thanks PassHours but still won't work.

    I forgot to mention that the page is in Japanese... Perhaps linebreaks in japanese text is different?  Am I supposed to change some configurations?


    Monday, July 28, 2008 7:51 AM
  • User2098859089 posted

    that is such a stupid. i have the same  problem. i didn't do anything. just copy and paste. and it didn't work :S:

    Friday, July 2, 2010 11:56 PM
  • User2098859089 posted

    i solved it but in a very strange way..

    i have a line like :

    <asp:AsyncPostBackTrigger ControlID="btnShow" EventName="Click" />

    if i remove this line and build project everything goes back to normal. but i can't use updatepanel for second button. weird thing about this : i used to use... i don't know what is wrong


    Saturday, July 3, 2010 2:36 AM
  • User-1802908944 posted

    use it


    Label01.Text.Replace(Environment.NewLine, "\n\t")

    Saturday, July 3, 2010 2:55 AM
  • User2098859089 posted

    actually this one worked for me : Replace("\n", "<br/>")

     it is still odd

    Saturday, July 3, 2010 5:12 AM