Reputation: 5114
How can I change the bgcolor
and font
of my asp:Literal
control?
Can you give me an example?
Upvotes: 9
Views: 25524
Reputation: 71
I have done this
<div style="color:rgba(255, 255, 255, 1)">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False" ></asp:Literal>
you can create a CSS class then put it inside a DIV
Upvotes: 1
Reputation: 7153
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.
Upvotes: 3
Reputation: 47766
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.
Upvotes: 5
Reputation: 1523
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>" />
Upvotes: 8
Reputation: 55172
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>";
Upvotes: 12