Click here to Skip to main content
16,006,605 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
in label i have Green (Text)

this Green text to be displayed in green color

similarly i have Red (text means)

this red text to be displayed in red color

for that how to do in asp.net using C#

What I have tried:

in label i have Green (Text)

this Green text to be displayed in green color

similarly i have Red (text means)

this red text to be displayed in red color

for that how to do in asp.net using C#
Posted
Updated 27-Jul-16 8:17am
Comments
Suvendu Shekhar Giri 27-Jul-16 3:34am    
Not clear. Share the code you have tried so far and explain bit more about your requirement.

try this

C#
string text  = "Red color Green color";
 text = text.Replace("Red", "<span style='color:red'>Red</span>");
 text = text.Replace("Green", "<span style='color:green'>Green</span>");
 lbl.Text = text;


// output
Red color Green color
 
Share this answer
 
Try:
C#
myLabel.Text = "red!";
myLabel.ForeColor = Color.Red;

C#
myLabel.Text = "green!";
myLabel.ForeColor = Color.Green;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900