Partilhar via


How to: Add RadioButton Web Server Controls to a Web Forms Page

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

  • By adding an individual RadioButton Web server control.

  • By adding a RadioButtonList Web server control and then adding individual list items to the control.

For details about the differences between these approaches, see RadioButton and RadioButtonList Web Server Controls Overview.

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 Web server controls to a Web Forms page

  1. From the Standard tab of the Toolbox, drag a RadioButton control onto the page.

  2. In the Properties window, specify a caption by setting the Text property.

  3. Optionally, change the orientation of the caption by setting the TextAlign property.

  4. Repeat steps 1 through 3 for each radio button that you want to add to your page.

To group individual RadioButton Web server 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 "RadioButtonGroup1" to the GroupName property of all the buttons.

    To create multiple groups of buttons, 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

Reference

RadioButton and RadioButtonList Web Server Controls Overview