Set formatting (color) on a literal or label

G

Guest

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 ""?
 
E

Elliot Rodriguez

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

Guest

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top