Solved

Display Text Without HTML Codes and Keep Formatting

Posted on 2013-06-10
3
805 Views
Last Modified: 2013-06-11
Hello,

I'm using tinyMCE 4.x, ASP.Net & VB - I successfully use the editor to encode text to html format and save it to a database.  Now I retrieve the text, for editing, to the textArea and it displays with the html text instead of diplaying text in format it was input at.  How do I correct this?  

Ex:
The dog jumped over the fence.
The cat swam through the river.

Shows up as: <p>The dog jumped over the fence.<br>The cat swam through the river.</p>

I looked at the TinyMCE API 4.x examples but it's not sinking in.  

Is there something I can do in either TinyMCE or in ASP.net - to have it display as it was originally entered?

Thanks
JS
0
Comment
Question by:jshesek
3 Comments
 
LVL 18

Accepted Solution

by:
Matthew Kelly earned 500 total points
ID: 39236540
When you said "encode" text, are you converting "<" to "&lt;" ? If so you would need to decode before putting back into the editor.

tinyMCE has a HTML view. Can you look to see if this is what is shown:

&lt;p&gt;The dog jumped over the fence.&lt;br&gt;The cat swam through the river.&lt;/p&gt;

Open in new window


If so, it is because your HTML is being converted to text and so tinyMCE thinks the < and the > are text instead of html tags.

You can't use HttpServerUtility.HtmlEncode for example because it will ruin TinyMce's content. TinyMce does it's own HTML encoding on client side. If you need to do server side encoding you will need to figure out what isn't html and only encode that (no idea how to go about that).
0
 
LVL 14

Expert Comment

by:dejaanbu
ID: 39236779
you need to comment encoding: 'xml' on your configuration.
0
 
LVL 1

Author Comment

by:jshesek
ID: 39237569
Ok got it to work.  But the formatting looks a little off.  Will investigate this further.

This is what I did:

The form is an edit form - so only 1 record was pulled with a datareader (dr)

TextBox1.Text = Server.HtmlDecode(dr("meetingNotes"))

Thanks for pointing me in the right direction.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question