ASP.NET HtmlInputRadioButton Control

Definition and Usage

The HtmlInputRadioButton control is used to control the <input type="radio"> element.

In HTML, this element is used to create radio buttons.

Properties

Properties Description
Attributes Returns all attribute names and value pairs of the element.
Checked Boolean value specifying whether the element is selected.
Disabled Boolean value indicating whether the control is disabled. The default is false.
id The unique id of the control
Name The name of the radio button group
runat Specifies that the control is a server control. It must be set to "server".
Style Sets or returns the CSS properties applied to the control.
TagName Returns the tag name of the element.
Type The type of the element.
Value The value of the element.
Visible Boolean value indicating whether the control is visible.

Example

HTMLInputRadiobutton
In this example, we declare three HtmlInputRadioButton controls, one HtmlInputButton control, and one HtmlGeneric control in the .aspx file. When the submit button is triggered, the submit subroutine is executed. The submit subroutine has three response modes: if the radio button with id="r1" is selected, the server sends the message "Your favorite color is red" to the p element. If the radio button with id="r2" is selected, the server sends the message "Your favorite color is green" to the p element. If the radio button with id="r3" is selected, the server sends the message "Your favorite color is blue" to the p element.