Linear control asp.net bgcolor

How can I change the bgcolor and font my asp:Literal control?

Can you give me an example?

+6
c # css webforms
source share
5 answers

Literal control means that it does not display any surrounding tags. So include the tags you want in the .Text property, and tag them accordingly.

eg.

 ltlFoo.Text = "<font style='background : orange;'>hello</font>"; 
+11
source share

Silky is absolutely right, but please, please, for my sanity, use CSS instead of inline styles:

 <style type="text/css"> .beautiful { font-family: Georgia, serif; color: #369; } </style> <asp:Literal ID="myLitControl" runat="server" Text="<div class='beautiful'>Some Beautiful Text</div>" /> 
+8
source share

Literal controls only display what you put in them, and nothing more.

Shortcut controls do the same, but wrap them in the gap where you could apply a style. Change your literal to shortcut and you should be kind.

+5
source share

I did it

 <div style="color:rgba(255, 255, 255, 1)"> <asp:Literal ID="FailureText" runat="server" EnableViewState="False" ></asp:Literal> 

you can create a CSS class and then put it in a div

+1
source share

Simple asp:Literal has a less control than style, so wrap it in another element, such as a div or span, and give the element a style.

0
source share

All Articles