asp.net文字控件bgcolor

Nag*_*agu 7 css c# asp.net webforms

我怎样才能改变bgcolorfont我的asp:Literal控制?

能给我举个例子?

Noo*_*ilk 11

文字控制意味着它不输出任何周围的标签.因此,在它的.Text属性中包含您想要的任何标记,并适当地标记它们.

例如

ltlFoo.Text = "<font style='background : orange;'>hello</font>";
Run Code Online (Sandbox Code Playgroud)


att*_*ack 8

Silky是完全正确的,但请为了我的理智,请使用CSS而不是内联样式:

<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>" />
Run Code Online (Sandbox Code Playgroud)


Kel*_*sey 5

文字控件只输出您放入其中的内容,没有别的.

标签控件执行相同操作,但将它们包装在您可以应用样式的范围中.将你的文字改为标签,你应该好好去.