asp.net mvc convert \n new line to html breaks

前端 未结 11 615
逝去的感伤
逝去的感伤 2020-12-14 15:10

I have a textarea in mvc. When data is entered into that and I\'m displaying it back to the user, how do I show the line breaks?

I display like this:

11条回答
  •  被撕碎了的回忆
    2020-12-14 15:56

    It doesn't look like you're trying to HTML Encode so a regular replace should work fine.

    <%= Model.Description.Replace(Environment.NewLine, "
    ")%>

提交回复
热议问题