Last post Aug 19, 2012 09:59 PM by young345
Aug 19, 2012 09:00 PM|young345|LINK
i have some html in a text file. i want to take the contents of this text file and display it on my webpage in a textarea.
however, it displays with all the html tags rather than applying the format and text.
does anyone know how i can display the content of the text file without the html tags and still have the format of the document?
also, when i submit the form, i need the text in the textarea to be in the format and not html because it is being sent in an email, therefore needs to include things like the line breaks.
any help on this would be much appreciated.
thank you very much
the following is the html and this is how it displays in the textarea as well. i need to remove the html tags but still have the format of the document
<p>this is my email</p>
<p>see you later</p>
Aug 19, 2012 09:02 PM|BrockAllen|LINK
Render with @Html.Raw(theHtmlString) to not perform HTML encoding.
Aug 19, 2012 09:25 PM|young345|LINK
please can you show me how i can apply that to the following as the html is displayed in a textarea.
@Html.TextAreaFor(model => model.myHtml)<br />
Aug 19, 2012 09:29 PM|BrockAllen|LINK
Sorry, i missed that you wanted all the formatting in a textarea (although you said that in the first sentence).
So let me understand -- if you have a <b>hello</b> in the text file you want it as bold text in the <textarea>?
Aug 19, 2012 09:36 PM|young345|LINK
yeah, so i have <br /> which means i want it to produce a line break rather than displaying <br />
Aug 19, 2012 09:38 PM|BrockAllen|LINK
Well, if it's just the <br /> you want to preserve then it's simple - just do a Replace("<br/>", "\r\n\r\n"). And then you'll have to convert the other way on the submit.
But if you want other formatting then you'll be out of luck unless you use some sort of rich text editor instead of a textarea.
Aug 19, 2012 09:59 PM|young345|LINK