简体   繁体   中英

asp.net literal control bgcolor

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

Can you give me an example?

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.

Eg

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

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>" />

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.

在简单的asp:Literal是一种较少控制的样式,因此将其与div或span等另一个元素包含在一起,并为此元素赋予样式。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM