Blinking and coloring asp.net label control

4.1k views Asked by At

I have a asp.net label control on my webform:

for this label I am setting the text property from code behind:

lblOne.Text = "Number of student is: 86 and Number of teacher is: 7";

Now I want to do 2 things:

  1. Blinking the label.
  2. Coloring: "Number of student is:" - RED Color "86" :- BLUE

             "and Number of teacher is:" - RED & 7:- BLUE
    

How can I do these things?

1

There are 1 answers

0
Hans Kesting On BEST ANSWER

Are you really sure you want that text to blink, the <blink> tag disappeared for a reason :-)

You could set a ForeColor for a label, but only for the complete Label. So what you could do is split that text into two labels, one blue and one red.

A different solution would be to use a Literal and set the html yourself:

Literal1.Text = String.Format("Number of student is: <span style='color:red'>{0}</style> and Number of teacher is: <span style='color:blue'>{1}</span>", student, teacher);