Wednesday, August 19, 2009

Convert String to System.Drawing.Color in ASPX C#

Here is a small example of how to convert a System.Drawing.Color to the HTML color format (Hex value or HTML color name value) and back.

System.Drawing.Color c = System.Drawing.ColorTranslator.FromHtml("#F5F7F8");
String strHtmlColor = System.Drawing.ColorTranslator.ToHtml(c);

No comments: