In previous asp.net server control post we had discussed about MultiView Control and ListBox Control and FileUpload Control and Adrotator Control and CheckBox Control and DropDownList Control and TextBox Control.
ASP.Net RadioButton Control
Radiobutton is a asp.net web server control. Radiobutton is used to allow user to select a single radiobutton from group of radiobutton. In a asp.net generally we use more than one radiobutton and select only one radiobutton at a time from all the radiobutton control. on other hand in checkbox control we can check and uncheck multiple check box at a time.
RadioButton Control ASP.Net Example
Now take an asp.net radiobutton example to understand more about radiobutton control.


HTML Design code for asp.net web forms:
<body> <form id="form1" runat="server"> <div> <table align="center" class="style1" style="border: thin solid #008080"> <tr> <td class="style2" style="text-align: center; border-bottom-style: solid; border-bottom-width: thin; border-bottom-color: #008080;"> RadioButton Control in ASP.Net</td> </tr> <tr> <td style="text-align: center"> </td> </tr> <tr> <td style="text-align: center"> <asp:RadioButton ID="radiored" runat="server" Text="RED" GroupName="my" /> <asp:RadioButton ID="radioblue" runat="server" Text="BLUE" GroupName="my" /> <asp:RadioButton ID="radiogreen" runat="server" Text="GREEN" GroupName="my" oncheckedchanged="radiogreen_CheckedChanged" /> </td> </tr> <tr> <td style="text-align: center"> <asp:Button ID="Button1" runat="server" Height="26px" onclick="Button1_Click" style="font-weight: 700" Text="Select" /> </td> </tr> <tr> <td style="text-align: center"> <asp:Label ID="Label1" runat="server"></asp:Label> </td> </tr> </table> </div> </form> </body>

code behind c# code :
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Default8 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (radiored.Checked == true) { Label1.Text = "You Selected Red"; } else if (radioblue.Checked == true) { Label1.Text = "You Selected Blue"; } else { Label1.Text = "You Selected Green"; } } }
