ShareThis

Sunday, June 17, 2012

[ASP] Set Asp Literal Style

ASP:Literal is simply rendered text. No style available unless it is defined in the text that is given for the literal; i.e. something like this:

<b> Hello, world! </b>
Would render bold. You can not set a style attribute on the Literal.

If you want to be able to set the style attribute, use an ASP:Label instead. It is rendered text wrapped in a <span> tag which allows for the setting of the style attribute.

This wont work:


<asp:Literal ID="myId" runat="server" style="font-weight:bold;"></asp:Label>


This will work:



<asp:Label ID="myId" runat="server" style="font-weight:bold;"></asp:Label>


0 comments:

Post a Comment