using C# I am saving formated HTML data in MSSQL such as:
<div>\n\t<p>x</p>\n</div>
I am than populating it into a textarea to display. I understand that I can use the .value property of the element to pull all of the ASCII characters out of the textarea, however, I can’t seem to figure out how to get the "\n" and "\t" characters to show up as new lines and tabs.
When I use FireBug to check the html contents of the textarea in question, this is what is displayed:
<div>/\n/\t<p>This is a test Div</p>/\n</div>
I don’t really care about using JavaScript to display the new lines and tabs, I can also use .NET to change the characters, I would just like to know either or both options.
Thanks much!
In .NET you can use String.Replace:
You might want to consider whether you should make this replacement before you insert the data into the database rather than as you fetch it, because you’ll probably only be inserting it once but fetching it a lot of times.
On the other hand, if you do it on the client then the work is offloaded from the server. But if they don’t have Javascript enabled, it will look wrong.