.NET Framework Class Library
WebControlForeColor Property

Gets or sets the foreground color (typically the color of the text) of the Web server control.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
Syntax
<[%$TOPIC/fs7y88ce_en-us_VS_110_1_0_0_0_0%](GetType([%$TOPIC/fs7y88ce_en-us_VS_110_1_0_0_0_1%]))> _
Public Overridable Property ForeColor As [%$TOPIC/fs7y88ce_en-us_VS_110_1_0_0_0_2%]
[[%$TOPIC/fs7y88ce_en-us_VS_110_1_0_1_0_0%](typeof([%$TOPIC/fs7y88ce_en-us_VS_110_1_0_1_0_1%]))]
public virtual [%$TOPIC/fs7y88ce_en-us_VS_110_1_0_1_0_2%] ForeColor { get; set; }
[[%$TOPIC/fs7y88ce_en-us_VS_110_1_0_2_0_0%](typeof([%$TOPIC/fs7y88ce_en-us_VS_110_1_0_2_0_1%]))]
public:
virtual property [%$TOPIC/fs7y88ce_en-us_VS_110_1_0_2_0_2%] ForeColor {
	[%$TOPIC/fs7y88ce_en-us_VS_110_1_0_2_0_3%] get ();
	void set ([%$TOPIC/fs7y88ce_en-us_VS_110_1_0_2_0_4%] value);
}
[<[%$TOPIC/fs7y88ce_en-us_VS_110_1_0_3_0_0%](typeof([%$TOPIC/fs7y88ce_en-us_VS_110_1_0_3_0_1%]))>]
abstract ForeColor : [%$TOPIC/fs7y88ce_en-us_VS_110_1_0_3_0_2%] with get, set
[<[%$TOPIC/fs7y88ce_en-us_VS_110_1_0_3_0_3%](typeof([%$TOPIC/fs7y88ce_en-us_VS_110_1_0_3_0_4%]))>]
override ForeColor : [%$TOPIC/fs7y88ce_en-us_VS_110_1_0_3_0_5%] with get, set
function get ForeColor () : [%$TOPIC/fs7y88ce_en-us_VS_110_1_0_4_0_0%] 
function set ForeColor (value : [%$TOPIC/fs7y88ce_en-us_VS_110_1_0_4_0_1%])

Property Value

Type: System.DrawingColor
A Color that represents the foreground color of the control. The default is Empty.
Remarks

Use the ForeColor property to specify the foreground color of the Web server control. The foreground color is usually the color of the text. This property will render on browsers earlier than Microsoft Internet Explorer version 4 for all controls, except the Image, AdRotator, HyperLink and LinkButton.

NoteNote

On browsers earlier than Microsoft Internet Explorer version 4, this property is rendered as <font> tags.

Examples

The following example illustrates how to set the ForeColor property of the Table control, inherited from the WebControl base class.

<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Table Property</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>Property of a Table Web Control</h3>

        <asp:Table id="Table1" runat="server"
            CellPadding = "10" 
            CellSpacing="0"
            GridLines="Both"
            Font-Bold="true"
            ForeColor="Red">

            <asp:TableRow>
                <asp:TableCell>
                    Row 0, Col 0
                </asp:TableCell>
                <asp:TableCell>
                    Row 0, Col 1
                </asp:TableCell>
            </asp:TableRow>

            <asp:TableRow>
                <asp:TableCell>
                    Row 1, Col 0
                </asp:TableCell>
                <asp:TableCell>
                    Row 1, Col 1
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
    </div>
    </form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Table Property</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>Property of a Table Web Control</h3>

        <asp:Table id="Table1" runat="server"
            CellPadding = "10" 
            CellSpacing="0"
            GridLines="Both"
            Font-Bold="true"
            ForeColor="Red">

            <asp:TableRow>
                <asp:TableCell>
                    Row 0, Col 0
                </asp:TableCell>
                <asp:TableCell>
                    Row 0, Col 1
                </asp:TableCell>
            </asp:TableRow>

            <asp:TableRow>
                <asp:TableCell>
                    Row 1, Col 0
                </asp:TableCell>
                <asp:TableCell>
                    Row 1, Col 1
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
    </div>
    </form>
</body>
</html>
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1