Dave
Dave

Reputation: 31

Preserve Line Breaks in ASP.NET Textbox

I have a multiline TextBox whose .Text property get saved in an SQL 2008 DB. When I submit the TextBox, I loose the returns. How do I handle this?

I've used Enviroment.Newline() to do some HTML conversion stuff, but I've never ran into this specific problem.

Edit: Nevermind, it was working just fine, but I was replacing "\n" incorrectly. Stupid mistake. I have to convert the "\n" to <p> tags. I've done this before, but if anybody wants to answer, I'll mark their answer as correct.

Upvotes: 3

Views: 4525

Answers (1)

Spudley
Spudley

Reputation: 168685

You've solved your own question already, which is great.

But I would comment on one thing: You say you're replacing \n with <p> but the way it sounds like you're doing it, I'd suggest replacing with <br> instead.

Cheers. -S.

Upvotes: 5

Related Questions