using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
namespace Colors
{
/// <summary>
/// ColorTable 的摘要说明
/// </summary>
public class ColorTable : System.Web.UI.UserControl
{
public ColorTable()
{
}
public override void RenderControl(HtmlTextWriter writer)
{
KnownColor[] colors = Enum.GetValues(typeof(KnownColor)) as KnownColor[];//#123456
writer.Write("<center><div style='width:500px'>");
foreach (KnownColor str in colors)
{
writer.Write("<input type='button' onClick='f(this)' style='height:20px; width:30px; background-color:" + str.ToString() + "' />");
}
writer.Write("</div></center>");
string javascript = "function f(e){document.body.bgColor = e.style.backgroundColor;}";
Page.ClientScript.RegisterStartupScript(this.GetType(), "code", javascript, true);
base.RenderControl(writer);
}
}
}