asp.net - How to change Chart background color

Chart background color
Chart is an asp.net web server control. chart control has a built in property to set or change its background color programmatically at run time.

Chart server control BackColor property allow us to get or set the background color of the chart object. this property value type is System.Drawing.Color. this 'Color' represents the background color of the chart object. the default background color of chart is System.Drawing.Color.White. so we can change the chart background color by setting a value of the BackColor property. we need to import the System.Drawing namespace to change the chart background color.

The following asp.net c# example code demonstrate us how can we set or change chart background color dynamically at run time in an asp.net application.
ChartBackColor.aspx

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        Chart1.BackColor = System.Drawing.Color.Green;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set change Chart BackColor (background color) in asp.net</title>
    <style type="text/css">
        h2
        {
            color:DodgerBlue;
            font-style:italic;
            }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2>How to set change Chart BackColor programmatically in asp.net</h2>
        <hr width="600" align="left" color="LightBlue" />
        <br />
        <asp:Chart ID="Chart1" runat="server" BackColor="OrangeRed">
            <Titles>
                <asp:Title 
                    Text="Sample chart of salary" 
                    BackColor="IndianRed" 
                    ForeColor="Snow"
                    BorderColor="DarkRed"
                    Font="Comic Sans MS"
                    BorderDashStyle="DashDot"
                    BorderWidth="1" 
                    >
                </asp:Title>
            </Titles>
            <Series>
                <asp:Series 
                    Name="Salary" 
                    YValueType="Int32" 
                    ChartType="Area" 
                    ChartArea="DefaultChartArea"
                    Color="HotPink"
                    >
                    <Points>
                        <asp:DataPoint AxisLabel="Santu" YValues="24300" />
                        <asp:DataPoint Color="Lavender" AxisLabel="Sakil" YValues="24795" />
                        <asp:DataPoint AxisLabel="Marufa" YValues="21550" />
                        <asp:DataPoint Color="Green" AxisLabel="Popy" YValues="32700" />
                        <asp:DataPoint AxisLabel="Sohag" YValues="26500" />
                    </Points>
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="DefaultChartArea" BackColor="Khaki" Area3DStyle-Enable3D="true">
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>
        <br />
        <asp:Button 
            ID="Button1"
            runat="server"
            Text="Set Chart BackColor Green"
            Font-Bold="true"
            OnClick="Button1_Click"
            Font-Names="Comic Sans MS"
            ForeColor="DarkBlue"
            Height="45"
            />
    </div>
    </form>
</body>
</html>