WebControl.BackColor Propriedade

Definição

Obtém ou define a cor da tela de fundo do controle do servidor Web.Gets or sets the background color of the Web server control.

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

Valor da propriedade

Color

Um Color que representa a cor da tela de fundo do controle.A Color that represents the background color of the control. O padrão é Empty, que indica que essa propriedade não está definida.The default is Empty, which indicates that this property is not set.

Atributos

Exemplos

O exemplo a seguir ilustra como definir a BackColor Propriedade do Table controle, que é herdada da WebControl classe base.The following example illustrates how to set the BackColor property of the Table control, which is inherited from the WebControl base class.

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

Comentários

Use a BackColor propriedade para especificar a cor do plano de fundo do controle do servidor Web.Use the BackColor property to specify the background color of the Web server control. Essa propriedade é definida usando um System.Drawing.Color objeto.This property is set using a System.Drawing.Color object.

Observação

Essa propriedade será processada somente para determinados controles.This property will render for only certain controls. Por exemplo,,,, Table Panel DataGrid Calendar e ValidationSummary irá renderizar essa propriedade.For example, Table, Panel, DataGrid, Calendar, and ValidationSummary will render this property. Ele também funcionará para CheckBoxList RadioButtonList o e DataList se sua RepeatLayout propriedade for RepeatLayout.Table , não RepeatLayout.Flow .It will also work for CheckBoxList, RadioButtonList and DataList if their RepeatLayout property is RepeatLayout.Table, not RepeatLayout.Flow.

Em geral, somente os controles que são renderizados como uma <table> marca podem exibir uma cor de plano de fundo em html 3,2, enquanto quase qualquer controle pode ser exibido em html 4,0.In general, only controls that render as a <table> tag can display a background color in HTML 3.2, whereas almost any control can in HTML 4.0.

Para controles que são renderizados como uma <span> marca (incluindo Label , todos os controles de validação e controles de lista com suas RepeatLayout Propriedades definidas como RepeatLayout.Flow ), essa propriedade funcionará no Microsoft Internet Explorer versão 5 e posterior, mas não no Microsoft Internet Explorer versão 4.For controls that render as a <span> tag (including Label, all validation controls, and list controls with their RepeatLayout property set to RepeatLayout.Flow), this property will work in Microsoft Internet Explorer version 5 and later, but not in Microsoft Internet Explorer version 4.

Aplica-se a

Confira também