Switch statement in asp.net c#

Switch statement
SwitchStatementExample.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e) {
        string li = RadioButtonList1.SelectedItem.Text;

        switch (li){
            case ("LightSlateGray"):
                RadioButtonList1.BackColor = System.Drawing.Color.LightSlateGray;
                RadioButtonList1.ForeColor = System.Drawing.Color.White;
                RadioButtonList1.BorderColor = System.Drawing.Color.Gray;
                break;

            case ("SteelBlue"):
                RadioButtonList1.BackColor = System.Drawing.Color.SteelBlue;
                RadioButtonList1.ForeColor = System.Drawing.Color.LightYellow;
                RadioButtonList1.BorderColor = System.Drawing.Color.MediumBlue;
                break;
                
            default:
                RadioButtonList1.BackColor = System.Drawing.Color.Gold;
                RadioButtonList1.ForeColor = System.Drawing.Color.Magenta;
                RadioButtonList1.BorderColor = System.Drawing.Color.DarkOrange;
                break;
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>asp.net switch statement example: switch, case, break, default</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy">Switch Statement Example</h2>
        <asp:RadioButtonList
             ID="RadioButtonList1"
             runat="server" 
             RepeatColumns="3" 
             BorderWidth="2" 
             AutoPostBack="true" 
             OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
             BackColor="Gold"
             ForeColor="Magenta"
             BorderColor="DarkOrange"
             >
            <asp:ListItem>IndianRed</asp:ListItem>
            <asp:ListItem>LightSlateGray</asp:ListItem>
            <asp:ListItem>LightCoral</asp:ListItem>
            <asp:ListItem>LightYellow</asp:ListItem>
            <asp:ListItem>LightSalmon</asp:ListItem>
            <asp:ListItem>Magenta</asp:ListItem>
            <asp:ListItem>SteelBlue</asp:ListItem>
        </asp:RadioButtonList>
    </div>
    </form>
</body>
</html>
More asp.net examples