Less Than and Greater Than Brackets in Web Pages

G

Greg

I know in regular HTML within a web page, you can use the following to
display < output > in the HTML output.

&lt output &gt

but, I'd rather not include any spaces between the less than and great than
signs, thus I want to see <output> instead. So, I tried using:

&ltappsettings&gt

and only 1/2 of it works. I get the following output instead:

&ltappsettings>

How can I make it so that my output shows as <output> with no spaces between
the less than sign and the first letter?
 
R

Rudy Velthuis

Greg said:
&ltappsettings&gt

and only 1/2 of it works. I get the following output instead:

&ltappsettings>

It should be &lt;appsetting&gt; (note the semicolons).

Try that.
 
A

Anthony Jones

Greg said:
Thanks, I literally just tried this a minute ago, and bingo, it works.
Thanks.

:

Its unclear whether you are doing this in ASP.NET or not however if not you
can reference the System.Web.dll then you can use:-

string sOut = HttpUtility.HtmlEncode("<appsettings>");

This will save you having to hunt down all the characters that need html DTD
entities such as <, > and &.

If you are doing this in an aspx page then the pages Server property can be
used:-

string sOut = Server.HtmlEncode("<appsettings>");
 
G

Greg

With further research last night I came across this method and it more
appropiately follow the path that I am taking, using ASP.NET pages. Thanks
for the reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top