Reputation: 2870
I have 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't.
How to add codes color to ForeColor
?
Is it possible?
Upvotes: 6
Views: 10256
Reputation: 6406
Use
hpl.ForeColor =System.Drawing.ColorTranslator.FromHtml("#5BB1E6");
Upvotes: 0
Reputation: 307
you can use following code, it may help you
HyperLink hpl = new HyperLink();
hpl.Text = "SomeText";
//use this
hpl.ForeColor = System.Drawing.Color.FromName("#5BB1E6")
hope it helps
Upvotes: 0
Reputation: 35582
Use the following code
HyperLink hpl = new HyperLink();
hpl.Text = "SomeText";
hpl.ForeColor = System.Drawing.ColorTranslator.FromHtml("#5BB1E6");
Upvotes: 11