Export (0) Print
Expand All

RadioButton

You can use two types of ASP.NET controls to add radio buttons to a page: individual RadioButton controls or a RadioButtonList control. Both controls allow users to select from a small set of mutually exclusive, predefined choices. The controls allow you to define any number of radio buttons with labels and to arrange them horizontally or vertically. For a comparison of RadioButton and RadioButtonList controls, see RadioButtonList.

To add a RadioButton control to a page

  1. Drag the RadioButton control from the Toolbox panel to your page.

  2. Set properties for the control in the Tag Properties panel.

Common RadioButton Properties

Property Description

Text

Specifies the label text displayed beside the radio button.

GroupName

Specifies the name of the group that the radio button belongs to. Only one radio button at a time can be selected in a group.

For a full description of all RadioButton control properties, see RadioButton Properties Cc295429.xtlink_newWindow(en-us,Expression.40).png in the MSDN library.

RadioButton Control HTML Attributes

When the RadioButton control renders to the browser, it does so in two parts: an INPUT element representing the radio button, and a separate LABEL element representing the caption for the radio button. The combination of the two elements is in turn wrapped in a SPAN element.

When you apply style or attribute settings to a RadioButton control, they are applied to the outer SPAN element. For example, if you set the control's BackColor property, the setting is applied to the SPAN tag, and therefore affects both the inner INPUT and LABEL elements.

At times, you might want to be able to make separate settings for the radio button and the label. The RadioButton control supports two properties that you can set at run time: the InputAttributes property and the LabelAttributes property. Each property allows you to add HTML attributes to the INPUT and LABEL elements, respectively. The attributes you set are passed through as-is to the browser.

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.

Community Additions

ADD
Show:
© 2014 Microsoft