using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
namespace myControls
{
public class ColorTable : WebControl
{
protected override void RenderContents(HtmlTextWriter writer)
{
KnownColor[] colors = (KnownColor[])Enum.GetValues(typeof(KnownColor));
writer.AddAttribute(HtmlTextWriterAttribute.Border, "1");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
foreach (KnownColor colorName in colors)
{
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write(colorName);
writer.RenderEndTag();
writer.AddAttribute(HtmlTextWriterAttribute.Width, "50px");
writer.AddAttribute(HtmlTextWriterAttribute.Bgcolor, colorName.ToString());
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write(" ");
writer.RenderEndTag();
writer.RenderEndTag();
}
writer.RenderEndTag();
}
}
}