asp.net.ph

Skip Navigation Links

Adding Individual RadioButton Controls to a Web Forms Page

Controls You Can Use on Web Forms   ASP.NET Standard Controls   RadioButton and RadioButtonList Controls


You can add radio buttons to a Web Forms page in two ways:

  • By adding individual RadioButton Web server controls and grouping them.
  • By adding a RadioButtonList control and adding individual list items to the control.

NOTE: This topic addresses how to add individual RadioButton controls to the page. For details about adding a RadioButtonList control, see Adding RadioButtonList Controls to a Web Forms.

For details about the differences in these approaches, see Introduction to the RadioButton and RadioButtonList Controls.

When you use individual RadioButton Web server controls, you typically add a set of them to the page and then group them. You can create multiple separate groups of buttons.

To add individual RadioButton controls to a Web Forms page

  1. Declare an <asp:RadioButton> element on the page. For syntax, see RadioButton Control Syntax.
  2. Specify a caption by setting the control’s Text property.
  3. Optionally change the orientation of the caption by setting the TextAlign property.
<asp:RadioButton id="Radio1" Text="button caption here" runat="server" />

To group individual RadioButton controls

  • Set the GroupName property of each control to the same name. You can use any string as the name, but do not include a space. For example, you might assign the string RadioGroup1 to the GroupName property of all the buttons.
<asp:RadioButton id="Radio1" Text="button caption here" GroupName="RadioGroup1" 
   runat="server" />
RadioButton1.aspx
Run Sample | View Source

To create multiple groups, use a different group name for each.

NOTE: You can add RadioButton controls to the page and group them with existing groups at any point.

See Also

Setting and Getting the Selection in a RadioButton Control   Responding to a User Selection in a RadioButton Group



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note