Reputation: 5620
I want to get data from textbox in plain HTML i.e if i write Hello World then it should return
Hello World
. I dont want to use HtmlEditor can i get plain html using textArea?
Upvotes: 0
Views: 322
Reputation: 218837
You're probably going to need to transform the text manually (with string.Replace()
or something similar) to accomplish this. Consider, for example, the "enter" and "space" tags you're looking for. If the user enters this as plain text (such as in a TextArea
):
Hello World
Another line
Then that's precisely the value that's in the TextArea
. The user didn't enter this:
Hello World<br />Another line
That's an entirely different string value. A WYSIWYG HTML editing control (and there are many for ASP.NET) would do some of the text transforms for you. At least it would probably convert the carriage returns into break tags for you.
But I doubt it would convert every space into a non-breaking space, since that's a very different value than what was entered. You'll likely have to do that yourself. (And be aware that converting all spaces into non-breaking spaces might not render the output like you expect. Look forward to a lot of horizontal scrolling.)
HTML isn't a translation of text into another medium, it's markup that's included in the text. Both of my examples above are perfectly valid HTML. One of them just doesn't include any markup tags.
Upvotes: 0
Reputation: 2101
http://www.dotnetperls.com/encode-html-string
If you really need the
you can always string-replace spaces
Upvotes: 1