WebControl.BackColor Propriété

Définition

Obtient ou définit la couleur d'arrière-plan du contrôle serveur Web.

public:
 virtual property System::Drawing::Color BackColor { 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 BackColor { get; set; }
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))]
public virtual System.Drawing.Color BackColor { get; set; }
[<System.ComponentModel.Bindable(true)>]
[<System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))>]
member this.BackColor : System.Drawing.Color with get, set
[<System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))>]
member this.BackColor : System.Drawing.Color with get, set
Public Overridable Property BackColor As Color

Valeur de propriété

Color qui représente la couleur d'arrière-plan du contrôle. La valeur par défaut, Empty, indique que cette propriété n'est pas définie.

Attributs

Exemples

L’exemple suivant montre comment définir la BackColor propriété du Table contrôle, qui est 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>BackColor Property</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>BackColor Property of a Web Control</h3>
 
        <asp:Table id="Table1" runat="server"
            CellPadding = "10" 
            GridLines="Both"
            BackColor="LightBlue">
            <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" %>
<!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>BackColor Property</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>BackColor Property of a Web Control</h3>
 
        <asp:Table id="Table1" runat="server"
            CellPadding = "10" 
            GridLines="Both"
            BackColor="LightBlue">
            <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 BackColor propriété pour spécifier la couleur d’arrière-plan du contrôle serveur Web. Cette propriété est définie à l’aide d’un System.Drawing.Color objet .

Notes

Cette propriété s’affiche uniquement pour certains contrôles. Par exemple, Table, Panel, DataGrid, Calendaret ValidationSummary affichent cette propriété. Elle fonctionne également pour CheckBoxList, RadioButtonList et DataList si leur RepeatLayout propriété est RepeatLayout.Table, et non RepeatLayout.Flow.

En général, seuls les contrôles qui s’affichent sous forme de <table> balise peuvent afficher une couleur d’arrière-plan dans HTML 3.2, alors que presque tous les contrôles le peuvent dans HTML 4.0.

Pour les contrôles qui s’affichent en tant que <span> balise (y compris Label, tous les contrôles de validation et contrôles de liste avec leur RepeatLayout propriété définie sur RepeatLayout.Flow), cette propriété fonctionne dans Microsoft Internet Explorer version 5 et ultérieure, mais pas dans Microsoft Internet Explorer version 4.

S’applique à

Voir aussi