ASP.NET RadioButton control

Definition and usage

The RadioButton control is used to display radio buttons.

Hint:To create a series of radio buttons that use data binding, use the RadioButtonList control!

Property

Property Description
AutoPostBack Boolean value, indicating whether the form is submitted immediately after the Checked property is changed. The default is false.
Checked Boolean value, indicating whether the radio button is selected.
id The unique id of the control.
GroupName The name of the control group to which the radio button belongs.
OnCheckedChanged The name of the function that is executed when Checked is changed.
runat Specifies that the control is a server control. It must be set to "server".
Text Text next to the radio button.
TextAlign Text should appear on which side of the radio button (left or right).

Web-Steuerungsstandardattribute

AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, 
CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled 
SkinID, Style, TabIndex, ToolTip, Width

Für eine vollständige Beschreibung besuchen Sie bitte Web-Steuerungsstandardattribute.

Steuerungsstandardattribute

AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls 
EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site 
TemplateControl, TemplateSourceDirectory, UniqueID, Visible

Für eine vollständige Beschreibung besuchen Sie bitteSteuerungsstandardattribute.

Beispiel

Radiobutton
In diesem Beispiel haben wir in der .aspx-Datei drei RadioButton-Steuerungen, eine Button-Steuerung und eine Label-Steuerung deklariert. Wenn der Submit-Button ausgelöst wird, wird der submit-Untersatz ausgeführt. Der submit-Untersatz reagiert auf drei Arten: Wenn der Radiobutton mit dem Attribut id="red" ausgewählt wird, sendet der Server eine Nachricht an die Label-Steuerung "Sie haben Rot ausgewählt"; wenn der Radiobutton mit dem Attribut id="green" ausgewählt wird, sendet der Server eine Nachricht an die Label-Steuerung "Sie haben Grün ausgewählt"; wenn der Radiobutton mit dem Attribut id="blue" ausgewählt wird, sendet der Server eine Nachricht an die Label-Steuerung "Sie haben Blau ausgewählt".