Grow your CSS skills. Land your dream job.

How to preserve line breaks in a textarea

  • # November 8, 2012 at 11:22 am

    Hello,

    Does anyone know how to preserve line breaks in a text area? I’m having a problem in our custom CMS where when you type something in a text area in the back end, the line breaks don’t show up on the front end. So it’ll look like this in the back end:

    text area

    text area

    text area

    But will come out like this on the front end:

    text area text area text area.

    I know it’s possible since this forum is obviously doing it, but I just have no clue how. Does anyone have an idea?

    # November 8, 2012 at 11:33 am

    It’s your custom CMS. How do you have your text fields set up?

    BTW, I had to edit your OP to get the original vertical ‘text areas’ to show properly so perhaps this forum isn’t the best example.

    # November 8, 2012 at 12:14 pm

    Ah, I guess maybe it isn’t. I just know it is set up using ASP.net. Our programmer only works on a limited basis so we’ve been trying to solve anything we can on our own. Maybe this is something that is beyond me that will need programming expertise. I was hoping there may be a simple solution.

    This is the code I pulled from the CMS that calls the text box

    # November 8, 2012 at 12:18 pm

    http://forums.asp.net/t/1572417.aspx/1

    # November 8, 2012 at 12:21 pm

    Where you output the string, something like:

    myString.Replace(“rn”, “
    “);

    # November 8, 2012 at 12:22 pm

    damnit… in the seconds parameter: < br > < br>

    # November 8, 2012 at 12:22 pm

    Awesome. Hopefully this bit of code they provide works within the asp tags. Thanks!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".