Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

On click of a button I am setting value of a Label1 as below.

Label1.Text="My name is wasif";

Now I want to display wasif in orange color.

How to implement it in code behind.

thanks
Posted

you can seperate your label string using string function string.split where characters need to be seperated based on space. This will return array of strings. You will get array. the on 3rd index of array, set your color .. you can use two different labels. the first label to show first three characters and another label to show name..
 
Share this answer
 
C#
label1.Text = "testing <font color='orange'>orange</font>";
 
Share this answer
 
v2
Try these
C#
label1.Text = "My name is <font color="#FFA500">Wasif</font>";
 
Share this answer
 
v2

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