How to show or hide Chart Legend in asp.net

Enable and disable (show and hide) Chart Legend programmatically
EnableDisableChartLegend.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        Chart1.Legends["Legend1"].Enabled = false;
    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        Chart1.Legends["Legend1"].Enabled = true;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to enable disable(show hide) Chart Legend programmatically in asp.net</title>
    <style type="text/css">
        h2
        {
            color:DarkBlue;
            font-style:italic;
            }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2>Chart example and tutorial: How to enable disable(show hide)<br /> Chart Legend programmatically in asp.net</h2>
        <hr width="625" align="left" color="LightBlue" />
        <br />
        <asp:Chart 
            ID="Chart1" 
            runat="server"
            Width="625" 
            BackColor="Purple"
            BorderlineColor="Orchid"
            BorderlineDashStyle="Dash"
            BorderlineWidth="2"
            >
            <Legends>
                <asp:Legend 
                    Name="Legend1"
                    BackColor="Crimson"
                    BackGradientStyle="DiagonalRight"
                    ForeColor="Snow"
                    BackSecondaryColor="Pink"
                    BorderColor="IndianRed"
                    >
                </asp:Legend>
            </Legends>
            <Series>
                <asp:Series 
                    Name="NokiaPhone" 
                    YValueType="Double" 
                    ChartArea="DefaultChartArea"
                    ChartType="Pie"
                    Palette="SemiTransparent"
                    >
                    <Points>
                        <asp:DataPoint AxisLabel="Nokia N8" YValues="549" />
                        <asp:DataPoint AxisLabel="Nokia N97 mini" YValues="379.99" />
                        <asp:DataPoint AxisLabel="X6 16GB Driver Edition" YValues="329" />
                        <asp:DataPoint AxisLabel="Nokia C6" YValues="309" />
                    </Points>
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea 
                    Name="DefaultChartArea" 
                    BorderDashStyle="Dot"
                    BorderWidth="2"
                    BorderColor="DarkOrchid"
                    BackColor="Orchid"
                    >
                    <Area3DStyle Enable3D="true" LightStyle="Realistic" />
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>
        <br />
        <asp:Button 
            ID="Button1"
            runat="server"
            Text="Hide Chart Legend"
            Font-Bold="true"
            OnClick="Button1_Click"
            ForeColor="DarkBlue"
            Height="45"
            />
        <asp:Button 
            ID="Button2"
            runat="server"
            Text="Show Chart Legend"
            Font-Bold="true"
            OnClick="Button2_Click"
            ForeColor="DarkBlue"
            Height="45"
            />
    </div>
    </form>
</body>
</html>
More asp.net chart examples