November Happy Hour will be moved to Thursday December 5th.

asp:label renders as inline

Vote:
 
Hi,

(I hope not posting this to the wrong forum. Maby it is a .net related question rather than an EPiServer question.)

Since I'm not really a .net developer but more of a designer with focus om W3C standards, I'm not sure whats giong on here. I've got my text output through a label control such as:

<asp:Label runat="server" ID="TextContent1"></asp:Label>

This will render:

<span id="ctl00_MySiteContent_TextContent1"></span>

'span' is an inline tag that does not allow block elements such as 'h1', 'h2', 'p' and so on inside it to validate with W3C (those block elements comes from the text editor, the content).

Is the only solution to do a <div runat="server"> to make the content holder a block element or is it possible to make the asp:label to render a 'div' instead of a 'span' (doing span{display:block; is not an option})?
#22524
Aug 07, 2008 15:13
Vote:
 
Well, you could make an adapter and override some renderfunction for asp:label, or you can use <div><asp:literal .. /></div> instead.
#22533
Aug 07, 2008 23:52
Vote:
 
Or use an <asp:Panel.... />
#22544
Aug 08, 2008 11:59
Vote:
 

I belive it would be helpful if you could try to explain "why" you would like to use extra tags at all.

 

Is it to be able to switch content "on and off" ? I.e. use Visible = <%# something() %> or similar?

 

Or is it just to output plain text to the webbpage?

#22547
Aug 08, 2008 13:16
Vote:
 

The ASP.NET Label control will render as a <label> element if you set the AssociatedControlID property.

If you want to render plain text, use the Literal control instead.

If you want to display/hide specific parts of a page, use the PlaceHolder control since it won't render any HTML whatsoever, except for the markup within the PlaceHolder tags.

#22629
Aug 09, 2008 22:16
Vote:
 

Thanx guys, your answers were helpful!

@Aanund:
I do not  understand your  question. As I stated in my first post  asp:label renders as an inline container e.g. <span><p>Content</p></span>. Since you cannon validate block elements (<p>, <ul> etc.) inside a span, I wanted to have a <div> instead so it renders <div><p>Content</p></div>. 

Chears! 

#22828
Aug 18, 2008 15:09
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.