Reputation: 21285
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 wondering if there is a standard solution to that either on server side (C#) or client side (javascript)
Upvotes: 2
Views: 5157
Reputation: 21285
Actually, I ended up replacing new line symbol with [br/] and it works very well.
Upvotes: -2
Reputation: 943510
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).
Upvotes: 4
Reputation: 1108702
Apply CSS white-space: pre;
on the <p>
element. This way any whitespace inside the element will be preserved.
Upvotes: 3