ColorTranslator.FromHtml : Color « Development « ASP.Net






ColorTranslator.FromHtml

<%@ Page Language="C#"  %>
<%@Import namespace="System.Collections"%>
<%@Import namespace="System.Drawing"%>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
  Hashtable myHash=new Hashtable();
  myHash.Add("Red", "#FF0000");
  myHash.Add("Green", "#00FF00");
  myHash.Add("Blue", "#0000FF");

  MyLabel.BackColor=ColorTranslator.FromHtml(myHash["Blue"].ToString());
  MyLabel.ForeColor=ColorTranslator.FromHtml(myHash["Red"].ToString());
  myHash=null;
}
</script>
<HTML>
  <body>
    <form id="form1" method="post" runat="server">
      <asp:Label ID="MyLabel" Runat="server">Sample Text</asp:Label><br>
    </form>
  </body>
</HTML>

 








Related examples in the same category

1.Create Color object from string (VB.net)
2.NET Standard Color Names (C#)
3.Color table (C#)