Convert textarea value to something suitable for span
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>
精彩评论