Load all colors names to dropdownlist using ASP.NET with C# Language

Some of the times we need to create a webpage, where user need to access the color. For this one, we can use System.Drawing.Color namespace. In the below example, i am taking all colors name from the .net framework.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <form id="form1" runat="server">
    <b>All Colors List from System.Drawing.Color</b>
    <asp:DropDownList ID="ddlColorLoad" runat="server"></asp:DropDownList>
    <br />

CSharp Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;

public partial class _Default : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e)
        foreach (System.Reflection.PropertyInfo property in typeof(Color).GetProperties())
            if (property.PropertyType.FullName == "System.Drawing.Color")

Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar