WebControl.ForeColor Propriété

Définition

Obtient ou définit la couleur de premier plan (généralement la couleur du texte) du contrôle serveur Web.

public:
 virtual property System::Drawing::Color ForeColor { System::Drawing::Color get(); void set(System::Drawing::Color value); };
[System.ComponentModel.Bindable(true)]
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))]
public virtual System.Drawing.Color ForeColor { get; set; }
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))]
public virtual System.Drawing.Color ForeColor { get; set; }
[<System.ComponentModel.Bindable(true)>]
[<System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))>]
member this.ForeColor : System.Drawing.Color with get, set
[<System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))>]
member this.ForeColor : System.Drawing.Color with get, set
Public Overridable Property ForeColor As Color

Valeur de propriété

Color qui représente la couleur de premier plan du contrôle. La valeur par défaut est Empty.

Attributs

Exemples

L’exemple suivant montre comment définir la ForeColor propriété du Table contrôle, héritée de la WebControl classe de base.

<%@ 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>
<%@ 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>

Remarques

Utilisez la ForeColor propriété pour spécifier la couleur de premier plan du contrôle serveur web. La couleur de premier plan est généralement la couleur du texte. Cette propriété s’affiche sur les navigateurs antérieurs à Microsoft Internet Explorer version 4 pour tous les contrôles, à l’exception de Image, AdRotatorHyperLink et LinkButton.

Notes

Sur les navigateurs antérieurs à Microsoft Internet Explorer version 4, cette propriété est affichée sous forme de <font> balises.

S’applique à

Voir aussi