Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Lets say I have a textArea and a user types a message in there. I want to save the message in the database but preserve formatting when the message is displayed at a later time. I'm currently storing the message as an varchar(1000) but none of the formatting line breaks get preserved. Any ideas on how to do this?
Posted
Comments
ArunRajendra 15-Jul-14 3:13am    
Text area does not put line break. It wraps text as per width.
Sergey Alexandrovich Kryukov 15-Jul-14 4:00am    
It's just not true. If wrapping works, line breaks play the role of paragraph breaks.
—SA
Thanks7872 15-Jul-14 3:25am    
I can't understand why people expect such a weird functionality. What will be the difference if some word will be displayed in second line of text area instead of first line?
Sergey Alexandrovich Kryukov 15-Jul-14 3:59am    
Those breaks are important enough, because what was just the line breaks originally, these days usually plays the role of paragraphs breaks. Anyway, all the text should be preserved. This is some OP's bug. One of the problems is that end-of-line character is system-dependent.
—SA
Sergey Alexandrovich Kryukov 15-Jul-14 4:01am    
Okay, you failed to preserve the break feature. But how can we know what exactly did you screw up? :-)
—SA

1 solution

You did not provide any useful information helping to resolve your problem. So, I can only give you a couple ideas.

After some thinking, I can to suggestion that in your text area you actually never had any line breaks. What seemed as line breaks for you could be just word wrapping of the text. The lines you saw as separate lines were actually, in terms of data, just parts of the same single line/paragraph.

To understand how line break works, please see: http://en.wikipedia.org/wiki/End_of_line[^].

Pay attention that the end-of-line string, is, unfortunately, system-dependent.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900