如何在mvc视图中显示新行\ n

时间:2016-02-25 18:18:36

标签: asp.net-mvc-4

 My actual problem is with the display.@Html.Raw(Html.Encode(@Model.DataText).Replace(Environment.NewLine, "<br />")) ...

在我的textarea文本中,新行是\ n ..和Environment.NewLine实际上是\ r \ n。因此它不会替换为break satement。我应该使用什么而不是Environment.NewLine。

1 个答案:

答案 0 :(得分:1)

添加style =“white-space:pre-line”会给人一种新线的印象。