Solved

Show html text inside html

Posted on 2011-03-12
9
243 Views
Last Modified: 2012-05-11
I need to show html text inside html code but it converting the text to html. For example the text "<b>bold text<b/> and &#38;" is placed inside a font tag like <font></font>. I want it to display as plain text rather than html converted text. Thanks.
0
Comment
Question by:sandya_116
9 Comments
 
LVL 4

Expert Comment

by:WhiteSeed
ID: 35117972
use plaintext:
<plaintext><b>you can see all this code<b></plaintext>
 
0
 
LVL 4

Expert Comment

by:WhiteSeed
ID: 35118034
i think now that with plaintext you can have problem with the close tag. you can use this system:

Instead of using a < sign, use the code
&lt;
Instead of using a > sign, use the code
&gt;
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35118047
The <plaintext> tag may not work as expected, e.g. on my up-to-date FireFox the closing </plaintext> tag is not recognized, thus everything after the opening tag is shown as plain text.

You will probably need to encode the special characters:

<font size="3" color="red">&lt;b&gt;you can see all this code, &amp;#38&lt;/b&gt;</font>

Open in new window


This website has a tool that will convert text for you: http://www.opinionatedgeek.com/dotnet/tools/htmlencode/encode.aspx
0
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

Author Comment

by:sandya_116
ID: 35118089
well the text is dynamically loaded so there could be bunch of characters that need to be encoded. Is there something else like plaintext tag.
0
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 500 total points
ID: 35118095
Well, if it's an ASP.Net web site you can HTML encode text on-the-fly with the Server.HtmlEncode() method, or using client-side JavaScript with the escape() method.
0
 
LVL 2

Expert Comment

by:niralbhavsar
ID: 35118862
You can try using a converter: http://girlswhogeek.com/tools/2010/code-converter
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35118867
I think a converter was already suggested, and doesn't do any good anyway since text is added to the page at run-time. ;)
0
 
LVL 8

Expert Comment

by:dmeeren
ID: 35121222
you could use the tags
<pre></pre>

Open in new window

0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35122841
<pre> tags won't work; they'll effectively remove any other HTML tags contained within them, and force the font to a fixed-width one, and since the asker specified the text to be displayed is inside a <font> tag I assume that's because he wants control over the font used.

"<font face="Tahoma"><pre><b>Hello World</b></pre></font>" will get you output that looks like:
Hello World

Open in new window


Whereas "<font face="Tahoma">&lt;b&gt;Hello World&lt;/b&gt;</font>" will get you output like:
<b>Hello World</b>
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

809 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