ASP.NET RadioButton Control

Definition and Usage

The RadioButton control is used to display radio buttons.

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

Attribute

Attribute Description
AutoPostBack Boolean value that specifies whether to immediately post back the form after the Checked property changes. The default is false.
Checked Boolean value that specifies 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 executed when the Checked property changes.
runat Specifies that the control is a server control. It must be set to "server".
Text Text next to the radio button.
TextAlign The text should appear on which side of the radio button (left or right)?

Τυποποιημένες Προσβλέψεις Web Ελέγχων

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

Για πλήρη περιγραφή, επισκεφθείτε Τυποποιημένες Προσβλέψεις Web Ελέγχων.

Τυποποιημένες Προσβλέψεις Ελέγχων

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

Για πλήρη περιγραφή, επισκεφθείτεΤυποποιημένες Προσβλέψεις Ελέγχων.

Παράδειγμα

Radiobutton
Σε αυτό το παράδειγμα, ανακήρυξα τρεις ελέγχους RadioButton στο αρχείο .aspx, έναν έλεγχο Button και έναν έλεγχο Label. Όταν ο κουμπί υποβολής ενεργοποιηθεί, εκτελείται η υποδικασία submit. Η υποδικασία submit θα απαντήσει με τρεις τρόπους: Αν ο radiobutton με την ιδιότητα id="red" επιλεγεί, ο σέρβιρος θα στείλει μήνυμα στον έλεγχο Label "Επιλέξατε το Κόκκινο"; Αν ο radiobutton με την ιδιότητα id="green" επιλεγεί, ο σέρβιρος θα στείλει μήνυμα στον έλεγχο Label "Επιλέξατε το Γραμμύ"; Αν ο radiobutton με την ιδιότητα id="blue" επιλεγεί, ο σέρβιρος θα στείλει μήνυμα στον έλεγχο Label "Επιλέξατε το Μπλε".