how to use radio button in c# asp.net code example

Example 1: c# sharp radio button in html how to

using System;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            radioButton1.Checked = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {
                MessageBox.Show ("You are selected Red !! ");
                return;
            }
            else if (radioButton2.Checked == true)
            {
                MessageBox.Show("You are selected Blue !! ");
                return;
            }
            else
            {
                MessageBox.Show("You are selected Green !! ");
                return;
            }
        }
    }
}

Example 2: radio button in asp.net

<asp:RadioButton GroupName="MeasurementSystem" runat="server" Text="US" />
<asp:RadioButton GroupName="MeasurementSystem" runat="server" Text="Metric" />