RadioButton Control

Radio button allows the user to choose only one of a predefined set of options. When a user clicks on a radio button, it becomes checked, and all other radio buttons with same group become unchecked. The buttons are grouped logically if they all share the same GroupName property.

radiobutoon-control VB.Net
RadioButton1.Checked = True
RadioButton1.Checked = true;

Use a radio button when you want the user to choose only one option. When you want the user to choose all appropriate options, use a check box.

The following ASP.NET program gives three option button to select. When the user select any option button , the label control displays the which option button is selected.


<html xmlns=""> <head id="Head1" runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:RadioButton ID="RadioButton1" GroupName="language" runat="server" Text="ASP.NET" /><br /> <asp:RadioButton ID="RadioButton2" GroupName="language" runat="server" Text="VB.NET" /><br /> <asp:RadioButton ID="RadioButton3" GroupName="language" runat="server" Text="C#" /><br /> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /><br /> <asp:Label ID="Label1" runat="server" Text="Label1"></asp:Label> </div> </form> </body> </html>
Full Source | C#
using System; public partial class _Default : System.Web.UI.Page { protected void Button1_Click(object sender, EventArgs e) { if (RadioButton1.Checked == true) { Label1.Text = "You selected : ASP.NET"; } else if (RadioButton2.Checked == true ) { Label1.Text = "You selected : VB.NET"; } else if (RadioButton3.Checked == true) { Label1.Text = "You selected : C#"; } else { Label1.Text = ""; } } }
Full Source | VB.NET
Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click If RadioButton1.Checked = True Then Label1.Text = "You selected : ASP.NET" ElseIf RadioButton2.Checked = True Then Label1.Text = "You selected : VB.NET" ElseIf RadioButton3.Checked = True Then Label1.Text = "You selected : C#" End If End Sub End Class

Click the following links to see full source code

C# Source Code
VB.NET Source Code