Hawkfield.Tech - Article based resources Hawkfield.Tech - Article based resources

Search this site
Search with Google

Archives

May 2007
February 2007
December 2006
April 2006
September 2005
August 2005
June 2005
May 2005
April 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004

Recent entries

Squidoo traffic ranker
ASP.NET "orcas"
Sorting custom objects in VB.NET
Validation over multiple servers
Implement the Calendar control
Controls in IE give 404 errors
Keeping control
Rejected-By-UrlScan
Slow servers
SQL transactions in .NET

Links

This site in XML
External links

Powered by

Movabletype

Hosted by

Hawkfield Web development

Related books

.NET ASP
Domains Google
PHP

Remove SPAN from PlaceHolder

When you put a PlaceHolder on your webpage and add stuff to it, asp.NET automatically adds a SPAN tag, which can be really annoying.



For example, say you have pieces of HTML code in a database and want to add them in different locations, you put a PlaceHolder in those locations to make sure you can add the HTML at runtime. However, say the HTML code is anything from <BODY> to </BODY> and .NET adds a SPAN tag around that, you would get illegal HTML in your output.

Many sites give a solution to enhance the functionality of the PlaceHolder by making your own PlaceHolder and customizing it in a User Control.

However, that is a little over the top.
Instead of using a PlaceHolder, try using a <asp:Literal> ... it will do just the same, without adding the SPAN tag. if you have the HTML code in a variable, here is an example on how to do it:

Literal lt = new Literal; // The literal control
String str = "<html>here</html>";
lt.Text = str;

This should not add any extra tags and make your HTML output compliant to the standards.

Posted by kajakske at 06/01/2005 11u31

Comments

Copyright 2004 © Hawkfield - All rights reserved