Export (0) Print
Expand All

How to: Add RadioButton Web Server Controls to a Web Forms Page (Visual Studio)

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.

    NoteNote

    This topic addresses how to add individual RadioButton controls to the page. For information about adding items to a RadioButtonList control, see How to: Add Items in List Web Server Controls.

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.

    NoteNote

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

See Also

Community Additions

ADD
Show:
© 2014 Microsoft