WebControl.BackColor プロパティ

定義

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

プロパティ値

コントロールの背景色を表す Color。 既定値は Empty です。このプロパティが設定されていないことを示します。

属性

次の例は、基本クラスから継承されるコントロールの プロパティをTable設定BackColorする方法をWebControl示しています。

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

注釈

Web サーバー コントロールの BackColor 背景色を指定するには、 プロパティを使用します。 このプロパティは、 オブジェクトを System.Drawing.Color 使用して設定されます。

Note

このプロパティは、特定のコントロールに対してのみレンダリングされます。 たとえば、TablePanelDataGridCalendar、 は、このプロパティをValidationSummaryレンダリングします。 また、 に対CheckBoxListRadioButtonListしても機能し、DataListプロパティRepeatLayoutが の場合は RepeatLayout.Table機能しませんRepeatLayout.Flow

一般に、HTML 3.2 ではタグとして <table> レンダリングされるコントロールのみが背景色を表示できますが、HTML 4.0 ではほぼすべてのコントロールを表示できます。

タグ (、すべての検証コントロール、およびプロパティが にRepeatLayout.Flow設定されたリスト コントロールをRepeatLayout含むLabel) として<span>レンダリングされるコントロールの場合、このプロパティは Microsoft Internet エクスプローラー バージョン 5 以降では機能しますが、Microsoft Internet エクスプローラー バージョン 4 では機能しません。

適用対象

こちらもご覧ください