|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
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 individualWeb server control.
By adding aWeb server control and then adding individual list items to the control.
This topic addresses how to add individual RadioButton controls to the page. For information about adding items to a RadioButtonList control, see.
For details about the differences between these approaches, see.
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
From the Standard tab of the Toolbox, drag a RadioButton control onto the page.
In the Properties window, specify a caption by setting theproperty.
Optionally, change the orientation of the caption by setting theproperty.
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 theproperty 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.
You can add RadioButton controls to the page and group them with existing groups at any point.