locked
how to include newline character in automapper? RRS feed

  • Question

  • User632751675 posted

    hi, 

    I'm using automapper to update fields in a database.  After the database is updated, the data can be viewed via web application.  I have one  field that contains data for three items. I would like to have each appear on a separate line so that it can be easily read.

    I have tried adding \n\r  , \n, system.environment variable, <br>, <\br>, in between the items.  None of these have worked, everything just wraps and it's hard to read..  it looks like newline chars are being removed or ignored.  Do you have any suggestions to make this work?

    Thank you!

    MG

    Sunday, January 17, 2021 2:22 AM

Answers

  • User-821857111 posted

    Automapper has nothing to do with your issue. It just assigns the existing values of a property on one class to another. It doesn't alter the values.

    If you want a new line to appear on the web page, you need to use <br>. You can store that in the text you save in the database, or you can use \n and replace it with <br> when you display the text. If you use a textarea to collect the data instead of a textbox, the \n is automatically added when the user hits their Enter key when they are typing the text.

    Maybe you should provide an example f the code you are using to collect and save the text.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 17, 2021 7:50 AM