I\'m using regular textbox as a text input where the users wrties their comments. I then use JQuery and JSON to send data to the server and then insert it into
where do you want to display the text? in a textarea or directly on the page?
if on the page you'll have to convert the newlines to <br/>
tags when getting the text from the db and printing it to the page.
I beleive this is down to the encoding you are using. Difference between unicode and ascii or something similar. It's been a while since I worked on something like this but I think it boiled down to two options.
Before writing out the HTML using javascript to the page, make sure to replace all the newlines with <br />
tags. Here is a simple extension for string that will allow you to do it using javascript (source):
String.prototype.NewlineToBR = function() {
return this.replace( /\r\n|\r|\n/g, br || '');
}
Usage:
var htmlString = newlineString.NewlineToBR();
Then just insert the new string into you HTML.
Just do like this answer: keep formatting entered in asp.net textbox (carriage return, new line, etc)
theStringYouWantToFormat.Replace(char.ConvertFromUtf32(13),"<br/>")