I have a form with several textarea elements. User enters data and submits the form. On the next page it shows submitted text as static text - in p tags. Obviously New Line and multiple paces get ignored and everything just shows in one line.
I can do some preprocessing like replacing New line characters with "br/" and spaces with . but I was wonderin开发者_开发技巧g if there is a standard solution to that either on server side (C#) or client side (javascript)Since the data is preformatted (and this isn't just a matter of presentation), the pre element would be suitable (you will still need to replace <
, &
and friends with the appropriate entities).
Apply CSS white-space: pre;
on the <p>
element. This way any whitespace inside the element will be preserved.
Actually, I ended up replacing new line symbol with [br/] and it works very well.
精彩评论