System.Web.UI.HtmlControls.HtmlInputRadioButton Class

Allows programmatic access to the HTML <input type= radio> element on the server.

See Also: HtmlInputRadioButton Members


public class HtmlInputRadioButton : HtmlInputControl, System.Web.UI.IPostBackDataHandler


Use the System.Web.UI.HtmlControls.HtmlInputRadioButton control to create a radio button on a Web page. The System.Web.UI.HtmlControls.HtmlInputRadioButton control does not provide built-in functionality to display a caption for the radio button. To create a caption, use literal text in the Web page at the desired location. This allows you to determine where the caption is displayed relative to the radio button. For example, if you want to display the caption on the right side of the radio button, declare an System.Web.UI.HtmlControls.HtmlInputRadioButton control, followed by the caption text, as shown in the following code.


 <input type="radio" 
 Caption Text<br>

You can optionally associate a quantity with the System.Web.UI.HtmlControls.HtmlInputRadioButton control by setting the HtmlInputRadioButton.Value property. This is useful when you have multiple radio buttons and need to perform a calculation, based on the selection.

System.Web.UI.HtmlControls.HtmlInputRadioButton controls can be grouped together by specifying a common value for the HtmlInputControl.Name property of each radio button you want to include in the group.


When you group System.Web.UI.HtmlControls.HtmlInputRadioButton controls together, only one radio button in the group can be selected at a time.

To determine whether the System.Web.UI.HtmlControls.HtmlInputRadioButton control is selected, test the HtmlInputRadioButton.Checked property. If you have a group of System.Web.UI.HtmlControls.HtmlInputRadioButton controls, you must iterate through the controls and test the HtmlInputRadioButton.Checked property of each control individually.

The System.Web.UI.HtmlControls.HtmlInputRadioButton control provides a HtmlInputRadioButton.ServerChange event that is raised when the HtmlInputRadioButton.Checked property changes values between posts to the server. This allows you to create a custom event handler that performs a specific set of instructions when the event is raised, such as data validation.

For a list of initial property values for an instance of System.Web.UI.HtmlControls.HtmlInputRadioButton, see the HtmlInputRadioButton.#ctor constructor.


Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0,