HOWTO: Remove <span> tag from Panel and PlaceHolder WebControls?

D

Don Wash

Hi There!

I'm creating my website with ASP.NET + XHTML, which means I will strictly
adhere the XHTML standards for my web page output.

I use Panel or PlaceHolder WebControls to place dynamically created
<div></div> contents to my web pages.

But the problem arises when because Panel and PlaceHolder WebControls do
extra work with <span> tags as follows...

Panel Control...
<div><span></span><div>

PlaceHolder Control...
<span><div><div></span>

In XHTML, it is not allowed to nest a <div> tag within a <span> tag. So
PlaceHolder control is now out of the question. So I use Panel control but
then it inserts the <span> tag inside the <div> tag (which is valid by the
way) BUT I need to insert <div> content to the Panel control from server
side. So the final output become something like this...

Using Panel Control...
<div><span><div id="MyOwnContent">Test</div></span><div>

So as you can see, now my "MyOwnContent" <div> tag is inside auto generated
<span> tag of the Panel control. So now my web page XHTML is invalid again.

How do I workaround this? Is there any properties that will turn off from
..NET automatically inserting <span> tags?

Thanks in advance,
Don
 
R

Rutger Smit

Don said:
Hi There!

I'm creating my website with ASP.NET + XHTML, which means I will strictly
adhere the XHTML standards for my web page output.

I use Panel or PlaceHolder WebControls to place dynamically created
<div></div> contents to my web pages.

But the problem arises when because Panel and PlaceHolder WebControls do
extra work with <span> tags as follows...

Panel Control...
<div><span></span><div>

PlaceHolder Control...
<span><div><div></span>

In XHTML, it is not allowed to nest a <div> tag within a <span> tag. So
PlaceHolder control is now out of the question. So I use Panel control but
then it inserts the <span> tag inside the <div> tag (which is valid by the
way) BUT I need to insert <div> content to the Panel control from server
side. So the final output become something like this...

Using Panel Control...
<div><span><div id="MyOwnContent">Test</div></span><div>

So as you can see, now my "MyOwnContent" <div> tag is inside auto generated
<span> tag of the Panel control. So now my web page XHTML is invalid again.

How do I workaround this? Is there any properties that will turn off from
.NET automatically inserting <span> tags?

Thanks in advance,
Don


Why not writing your own server control?
With a good book about server controls it won't be that dificult.
Writing an alternative for the Placeholder or Panel control is the
simples example IMHO.

Reccomended book: http://www.microsoft.com/MSPress/books/5728.asp

--

//Rutger

(e-mail address removed)
www.RutgerSmit.com
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top