Partilhar via


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

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

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. Type an <asp:RadioButton> element onto the page. For syntax, see RadioButton Web Server Control.

  2. Specify a caption by setting the Text property.

    NoteNote

    CheckBox is the base class for RadioButton.

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

  4. Repeat steps 1 through 3 for each radio button.

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 "RadioButtonGroup1" to the GroupName property of all the buttons.

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

    NoteNote

    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