How to: Set Web Server Control Color Properties

To set a Web server control property such as the BackColor property to a color, you assign a reference to the Color object.

To set Web server control properties to a color

  • Call the Color object's FromArgb method, passing it a numeric value (RGB) or the FromName passing it the name of a color as string. Alternatively, you can assign the color using a static method that references a predefined color name, as in the following example:

    Button1.BackColor = System.Drawing.Color.FromName("Red")
    ' White in RGB.
    Button1.BackColor = System.Drawing.Color.FromArgb(255, 255, 255)
    Button1.BackColor = System.Drawing.Color.Red
    ' HTML 4.0 Color
    Button1.BackColor = System.Drawing.Color.MediumSeaGreen
    
    Button1.BackColor = System.Drawing.Color.FromName("Red");
    // White in RGB.
    Button1.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
    Button1.BackColor = System.Drawing.Color.Red;
    // HTML 4.0 color.
    Button1.BackColor = System.Drawing.Color.MediumSeaGreen;
    

See Also

Tasks

How to: Set ASP.NET Server Control Style Properties Programmatically

Other Resources

ASP.NET Themes and Skins