How to use RadioButton control in asp.net c#

RadioButton web server control
RadioButton control lets you make a group of radio buttons with other RadioButton. If you set it's GroupName property same for multiple radio buttons then all radio buttons with same name act as a single group. Within a group you can only select one RadioButton at a time. RadioButton group work as like RadioButtonList. With RadioButton control you can more customize it than RadioButtonList items.

Back color, border color, border style, font names, font bold, font italic, fore color (text color) and many more property help you to design RadioButton. It also support CSS class, theme and skin. Even validation are works with RadioButton control. RadioButton have AutoPostBack property and CheckChanged event. By using those feature you can determine immediately which RadioButton is selected from a group.

This example uses a RadioButton group with two RadioButton. Here we assign AutoPostBack property value to true and setup a CheckChanged event. When you select a RadioButton from this group, the web browser show which RadioButton is selected (checked).
RadioButtonHowToUse.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void RadioButton_CheckedChanged(object sender,System.EventArgs e) {
        if (RadioButton1.Checked == true)
        {
            Label1.Text = "Your selected item is : " +
                RadioButton1.Text;
        }
        else {
            Label1.Text = "Your selected item is : " +
                RadioButton2.Text;
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>How to use RadioButton control in asp.net</title>
    </head>
<body style="padding:25px">
    <form id="form1" runat="server">
        <div>
            <h2 style="color:MidnightBlue; font-style:italic;">      
                How to use RadioButton control
            </h2>      
            <hr width="450" align="left" color="Gainsboro" />
            <asp:Label
                 ID="Label1"
                 runat="server"
                 Font-Bold="true"
                 Font-Names="Comic Sans MS"
                 ForeColor="Crimson"
                 Font-Italic="true"
                 Font-Size="X-Large"
                />
            <br /><br />
            <asp:Label
                 ID="Label2"
                 runat="server"
                 Text="Choose an item..."
                 Font-Bold="true"
                 Font-Names="Book Antiqua"
                 Font-Size="Larger"
                 Font-Underline="true"
                />
            <br />
            <asp:RadioButton 
                ID="RadioButton1" 
                runat="server" 
                Text="ASP.NET" 
                GroupName="Software" 
                AutoPostBack="true" 
                OnCheckedChanged="RadioButton_CheckedChanged"
                Font-Bold="true"
                Font-Names="Courier New"
                Font-Size="XX-Large"
                ForeColor="Navy"
                />
            <asp:RadioButton 
                ID="RadioButton2" 
                runat="server" 
                Text="ColdFusion"
                GroupName="Software" 
                AutoPostBack="true" 
                OnCheckedChanged="RadioButton_CheckedChanged"
                Font-Bold="true"
                Font-Names="Courier New"
                Font-Size="XX-Large"
                ForeColor="Navy"
                />
        </div>
    </form>
</body>
</html>
More asp.net examples