开发者

Convert textarea value to something suitable for span

开发者 https://www.devze.com 2023-03-14 23:08 出处:网络
I have data taken from a textarea an开发者_运维技巧d put into a database. It is then returned from the database, and I want to put it into a span tag with the formatting still intact. Is there a metho

I have data taken from a textarea an开发者_运维技巧d put into a database. It is then returned from the database, and I want to put it into a span tag with the formatting still intact. Is there a method that does this? I have tried

.Replace("\r\n", "<br />")

which fixes the line breaks, but that still leaves the whitespace and.. I am sure there has to be a built-in method somewhere.


Easiest solution is to mark your span as pre-formatted:

<span style="white-space:pre">text from textarea here</span>
0

精彩评论

暂无评论...
验证码 换一张
取 消