tags:

views:

28

answers:

2

Hi,

Probably simple question but it has been a long time since i work with UI,

I have a textarea that the user can enter his input. I'm saving the input into sql server table. when i want to display the input all the breaks that the user entered are gone. I remember there was a way to replace char 13 with <br/> (did that with classic ASP)

I wonder if there is any better way to over come this problem with asp.net,

Thanks.

+2  A: 

You can use String.Replace to replace the \r and/or \n characters with <br/>. Of course you'll probably want to do that on the way out, not on the way in.

John M Gant
i thought asp.net will have more elegant way... seems to me like a very common task ?!?!
UshaP
+1  A: 

Assuming the line-breaks are indeed stored in your DB, you could always surround the html when you display it within <pre> tags to preserve the line breaks in the display.

JohnFx
I'm not sure i follow. what do you mean "display it with tags"
UshaP
sorry. the actual tag in my answer got interpreted as a literal tag and wasn't being displayed in the answer. see my corrected answer.
JohnFx
Yes this is exactly what i was looking for - thank you :)
UshaP