Gets or sets the background color of the Web server control.
Assembly: System.Web (in System.Web.dll)
<[%$TOPIC/4z9y885f_en-us_VS_110_1_0_0_0_0%](GetType([%$TOPIC/4z9y885f_en-us_VS_110_1_0_0_0_1%]))> _
Public Overridable Property BackColor As [%$TOPIC/4z9y885f_en-us_VS_110_1_0_0_0_2%]
[[%$TOPIC/4z9y885f_en-us_VS_110_1_0_1_0_0%](typeof([%$TOPIC/4z9y885f_en-us_VS_110_1_0_1_0_1%]))]
public virtual [%$TOPIC/4z9y885f_en-us_VS_110_1_0_1_0_2%] BackColor { get; set; }
[[%$TOPIC/4z9y885f_en-us_VS_110_1_0_2_0_0%](typeof([%$TOPIC/4z9y885f_en-us_VS_110_1_0_2_0_1%]))]
public:
virtual property [%$TOPIC/4z9y885f_en-us_VS_110_1_0_2_0_2%] BackColor {
[%$TOPIC/4z9y885f_en-us_VS_110_1_0_2_0_3%] get ();
void set ([%$TOPIC/4z9y885f_en-us_VS_110_1_0_2_0_4%] value);
}
[<[%$TOPIC/4z9y885f_en-us_VS_110_1_0_3_0_0%](typeof([%$TOPIC/4z9y885f_en-us_VS_110_1_0_3_0_1%]))>]
abstract BackColor : [%$TOPIC/4z9y885f_en-us_VS_110_1_0_3_0_2%] with get, set
[<[%$TOPIC/4z9y885f_en-us_VS_110_1_0_3_0_3%](typeof([%$TOPIC/4z9y885f_en-us_VS_110_1_0_3_0_4%]))>]
override BackColor : [%$TOPIC/4z9y885f_en-us_VS_110_1_0_3_0_5%] with get, set
<asp:[%$TOPIC/4z9y885f_en-us_VS_110_1_0_4_0_0%] BackColor="[%$TOPIC/4z9y885f_en-us_VS_110_1_0_4_0_1%]" />
Property Value
Type: System.DrawingColorA Color that represents the background color of the control. The default is Empty, which indicates that this property is not set.
Use the BackColor property to specify the background color of the Web server control. This property is set using a System.DrawingColor object.
Note |
|---|
This property will render for only certain controls. For example, Table, Panel, DataGrid, Calendar, and ValidationSummary will render this property. It will also work for CheckBoxList, RadioButtonList and DataList if their RepeatLayout property is RepeatLayout.Table, not RepeatLayout.Flow. |
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.
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.
The following example illustrates how to set the BackColor property of the Table control, which is inherited from the WebControl base class.
<%@ 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>
<%@ 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>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note