本文介绍了从数据库中显示文本时,保持空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我张贴,从表中显示值的表。其中一个字段来自一个textarea输入。

I'm putting up a table that displays values from a table. One of the fields comes from a textarea input.

如果我用这个方法,那么空白保持:

If I use this method then whitespace is maintained:

@Html.TextAreaFor(model => model.goalDescr, new { cols="90", rows="3", @readonly = "true"})

- 例如:

- 结束例如

不过,我不喜欢这种看法了这么多,因为它仍然看起来像一个表单域。我试图用displayfor但白色的空间被删除,所有的文字一一一行。

However, I don't like that view so much as it still looks like a form field. I tried to use displayfor but the white space is removed and all text is one one line.

@Html.DisplayFor(model => model.goalDescr)

- 例如:

- 结束例如

有没有在显示在我看来文字,表单元素之外,保持空白的方式?

Is there a way to display text in my view in, outside of a form element, and maintain white space?

推荐答案

包住DB的内容插入到

wrap your DB content into a pre tag

<pre>
 All whitespaces      and linebreaks
are preserved

</pre>

这篇关于从数据库中显示文本时,保持空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 01:58