Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net literal control bgcolor

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

Can you give me an example?

like image 721
Nagu Avatar asked Aug 13 '09 04:08

Nagu


4 Answers

In simple asp:Literal is a style less control, so enclose this with another element like div or span and give style to this element.

like image 136
Saahithyan Vigneswaran Avatar answered Oct 06 '22 00:10

Saahithyan Vigneswaran


Literal control means it doesn't output any surrounding tags. So include whatever tags you want in the .Text property of it and mark them appropriately.

E.g.

ltlFoo.Text = "<font style='background : orange;'>hello</font>";
like image 44
Noon Silk Avatar answered Nov 14 '22 08:11

Noon Silk


Silky is totally 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>" />
like image 8
attack Avatar answered Nov 14 '22 08:11

attack


Literal controls only output exactly what you put in them, nothing else.

Label controls do the same but wrap them in a span which you could do apply a style to. Change your Literal to a Label and you should be good to go.

like image 5
Kelsey Avatar answered Nov 14 '22 08:11

Kelsey