Set formatting (color) on a literal or label

Discussion in 'ASP .Net' started by =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=, Mar 9, 2006.

  1. We have a status message we display that can be good news (in green) or bad
    news (in red). Is there a way to do this for a single literal or label? Or do
    we need to have two, one set to green and one to red and just set one to a
    text string and the other to ""?

    --
    thanks - dave
    david_at_windward_dot_net
    http://www.windwardreports.com
     
    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=, Mar 9, 2006
    #1
    1. Advertising

  2. Dim GoodNews as Boolean
    .....
    If GoodNews Then
    MessageLabel.Font.Color = Color.Green
    Else
    MessageLabel.Font.Color = Color.Red
    End If



    "David Thielen" <> wrote in message
    news:...
    > We have a status message we display that can be good news (in green) or
    > bad
    > news (in red). Is there a way to do this for a single literal or label? Or
    > do
    > we need to have two, one set to green and one to red and just set one to a
    > text string and the other to ""?
    >
    > --
    > thanks - dave
    > david_at_windward_dot_net
    > http://www.windwardreports.com
    >
     
    Elliot Rodriguez, Mar 9, 2006
    #2
    1. Advertising

  3. If you do it using a Literal you can set the Text property to the complete
    markup e.g.
    If GoodNews Then
    Literal1.Text = "<span class='greencolorCss'>this is the status
    for good news </span>"
    Else
    Literal1.Text = "<span class='redcolorCss'>this is the status
    for bad news </span>"
    End If

    If you do it using a Label you might write:
    If GoodNews Then
    Label1.CssClass = "greencolorCss"
    Label1.Text = "This is the status for good news"

    Else
    Label1.CssClass = "redcolorCss"
    Label1.Text = "This is the status for bad news"
    End If
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "David Thielen" wrote:

    > We have a status message we display that can be good news (in green) or bad
    > news (in red). Is there a way to do this for a single literal or label? Or do
    > we need to have two, one set to green and one to red and just set one to a
    > text string and the other to ""?
    >
    > --
    > thanks - dave
    > david_at_windward_dot_net
    > http://www.windwardreports.com
    >
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Mar 9, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    Literal vs. LiteralControl vs. Label

    =?Utf-8?B?Sm9l?=, Nov 11, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    50,889
    feddas
    Dec 30, 2008
  2. Anonieko Ramos

    What's wrong with rpc-literal? Why use doc-literal?

    Anonieko Ramos, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    412
    Anonieko Ramos
    Sep 27, 2004
  3. Armin Roehrl
    Replies:
    2
    Views:
    159
    Armin Roehrl
    Feb 10, 2004
  4. Kamaljeet Saini
    Replies:
    0
    Views:
    500
    Kamaljeet Saini
    Feb 13, 2009
  5. Knut Krueger
    Replies:
    8
    Views:
    336
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page