ForeColor with color codes

I created dynamically HyperLink. And I want to change the color by adding a color code.

HyperLink hpl = new HyperLink();
hpl.Text = "SomeText";
hpl.ForeColor = "#5BB1E6";

//Cannot implicitly convert type 'string' to 'System.Drawing.Color

But I can not.

How to add color code in ForeColor?

Is it possible?

+5
source share
3 answers

Use the following code

HyperLink hpl = new HyperLink();
hpl.Text = "SomeText";
hpl.ForeColor = System.Drawing.ColorTranslator.FromHtml("#5BB1E6");
+10
source

Use

hpl.ForeColor =System.Drawing.ColorTranslator.FromHtml("#5BB1E6");
0
source

you can use the following code, it can help you

HyperLink hpl = new HyperLink();
hpl.Text = "SomeText";
//use this
hpl.ForeColor = System.Drawing.Color.FromName("#5BB1E6")

hope this helps

0
source

All Articles