Solved

Display Text Without HTML Codes and Keep Formatting

Posted on 2013-06-10
3
622 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now