WebControl.BackColor Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene o imposta il colore di sfondo del controllo server 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
Valore della proprietà
Oggetto Color che rappresenta il colore di sfondo del controllo. Il valore predefinito è Empty, che indica che questa proprietà non è impostata.
- Attributi
Esempio
Nell'esempio seguente viene illustrato come impostare la BackColor proprietà del Table controllo , ereditata dalla WebControl classe di 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>
Commenti
Utilizzare la BackColor proprietà per specificare il colore di sfondo del controllo server Web. Questa proprietà viene impostata utilizzando un System.Drawing.Color oggetto .
Annotazioni
Verrà eseguito il rendering di questa proprietà solo per determinati controlli. Ad esempio, Table, PanelDataGrid, Calendar, e ValidationSummary eseguirà il rendering di questa proprietà. Funzionerà anche per CheckBoxListe se la proprietà RepeatLayout è RepeatLayout.Table, non RepeatLayout.Flow.DataListRadioButtonList
In generale, solo i controlli di cui viene eseguito il rendering come <table> tag possono visualizzare un colore di sfondo in HTML 3.2, mentre quasi qualsiasi controllo può essere incluso in HTML 4.0.
Per i controlli di cui viene eseguito il rendering come <span> tag (inclusi Label, tutti i controlli di convalida e i controlli elenco con la relativa RepeatLayout proprietà impostata su RepeatLayout.Flow), questa proprietà funzionerà in Microsoft Internet Explorer versione 5 e successive, ma non in Microsoft Internet Explorer versione 4.