RadioButton クラス
アセンブリ: System.Web (system.web.dll 内)

Public Class RadioButton Inherits CheckBox Implements IPostBackDataHandler
public class RadioButton : CheckBox, IPostBackDataHandler
public class RadioButton extends CheckBox implements IPostBackDataHandler
public class RadioButton extends CheckBox implements IPostBackDataHandler

RadioButton サーバー コントロールを使用すると、ページ内のほかの内容の間にグループでオプション ボタンを配置できます。すべてのボタンが同じ GroupName プロパティを共有している場合、ボタンは論理的にグループ化されます。
![]() |
---|
RadioButton コントロールを使用すると、ユーザー入力を表示できますが、ユーザー入力には悪意のあるクライアント スクリプトが含まれている可能性があります。アプリケーションに表示する前に、クライアントから送信された実行スクリプト、SQL ステートメントなどのコードの情報はすべて検査してください。ASP.NET には入力要求の検証機能があり、ユーザー入力の中のスクリプトと HTML をブロックできます。検証サーバー コントロールは、ユーザー入力を査定する目的でも用意されています。詳細については、「検証サーバー コントロール構文」を参照してください。 |
ユーザー補助
このコントロールに既定でレンダリングされるマークアップは、Web Content Accessibility Guidelines (WCAG) 1.0 の優先度 1 ガイドラインなどのユーザー補助に関する標準に適合しない可能性があります。このコントロールのユーザー補助サポートの詳細については、「ASP.NET コントロールとユーザー補助」を参照してください。

RadioButton コントロールを使用する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script language="VB" runat="server"> Sub SubmitBtn_Click(Sender As Object, e As EventArgs) If Radio1.Checked Then Label1.Text = "You selected " & Radio1.Text ElseIf Radio2.Checked Then Label1.Text = "You selected " & Radio2.Text ElseIf Radio3.Checked Then Label1.Text = "You selected " & Radio3.Text End If End Sub </script> </head> <body> <h3>RadioButton Example</h3> <form runat=server> <h4>Select the type of installation you want to perform:</h4> <asp:RadioButton id=Radio1 Text="Typical" Checked="True" GroupName="RadioGroup1" runat="server" /><br> This option installs the features most typically used. <i>Requires 1.2 MB disk space.</i><p> <asp:RadioButton id=Radio2 Text="Compact" GroupName="RadioGroup1" runat="server"/><br> This option installs the minimum files required to run the product. <i>Requires 350 KB disk space.</i><p> <asp:RadioButton id=Radio3 runat="server" Text="Full" GroupName="RadioGroup1" /><br> This option installs all features for the product. <i>Requires 4.3 MB disk space.</i><p> <asp:button text="Submit" OnClick="SubmitBtn_Click" runat=server/> <asp:Label id=Label1 font-bold="true" runat="server" /> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat="server"> void SubmitBtn_Click(Object Sender, EventArgs e) { if (Radio1.Checked) { Label1.Text = "You selected " + Radio1.Text; } else if (Radio2.Checked) { Label1.Text = "You selected " + Radio2.Text; } else if (Radio3.Checked) { Label1.Text = "You selected " + Radio3.Text; } } </script> </head> <body> <h3>RadioButton Example</h3> <form runat=server> <h4>Select the type of installation you want to perform:</h4> <asp:RadioButton id=Radio1 Text="Typical" Checked="True" GroupName="RadioGroup1" runat="server" /><br> This option installs the features most typically used. <i>Requires 1.2 MB disk space.</i><p> <asp:RadioButton id=Radio2 Text="Compact" GroupName="RadioGroup1" runat="server"/><br> This option installs the minimum files required to run the product. <i>Requires 350 KB disk space.</i><p> <asp:RadioButton id=Radio3 runat="server" Text="Full" GroupName="RadioGroup1" /><br> This option installs all features for the product. <i>Requires 4.3 MB disk space.</i><p> <asp:button text="Submit" OnClick="SubmitBtn_Click" runat=server/> <asp:Label id=Label1 font-bold="true" runat="server" /> </form> </body> </html>

System.Web.UI.Control
System.Web.UI.WebControls.WebControl
System.Web.UI.WebControls.CheckBox
System.Web.UI.WebControls.RadioButton


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


RadioButton メンバ
System.Web.UI.WebControls 名前空間
CheckBox クラス
その他の技術情報
RadioButton Web サーバー コントロールおよび RadioButtonList Web サーバー コントロール
RadioButton クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

<ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ Public Class RadioButton Inherits ButtonBase
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] public class RadioButton : ButtonBase
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] public ref class RadioButton : public ButtonBase
/** @attribute ComVisibleAttribute(true) */ /** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ public class RadioButton extends ButtonBase
ComVisibleAttribute(true) ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) public class RadioButton extends ButtonBase

RadioButton コントロールには、テキストおよび Image、またはその両方を表示できます。
ユーザーがグループ内のオプション ボタンの 1 つを選択すると、他のボタンは自動的にオフになります。特定のコンテナ内にある Form などのすべての RadioButton コントロールは、1 つのグループとなります。1 つのフォーム上に複数のグループを作成する場合は、グループを GroupBox コントロールや Panel コントロールなどの独自のコンテナに配置します。
RadioButton コントロールと CheckBox コントロールには似た機能があり、ユーザーが選択または選択解除できる選択肢を表示します。相違点は、CheckBox コントロールが同時に複数選択できるのに対して、オプション ボタンは一度に 1 つしか選択できない点です。
Checked プロパティを使用して、RadioButton の状態を取得または設定します。オプション ボタンの外観は、Appearance プロパティを設定して変更でき、トグル スタイルのボタンまたは標準のオプション ボタンで表示できます。

RadioButton を作成および初期化し、トグル ボタンのような外観にするコード例を次に示します。AutoCheck プロパティを false に設定して、ボタンを Form に追加します。
Private Sub InitializeMyRadioButton() ' Create and initialize a new RadioButton. Dim radioButton1 As New RadioButton() ' Make the radio button control appear as a toggle button. radioButton1.Appearance = Appearance.Button ' Turn off the update of the display on the click of the control. radioButton1.AutoCheck = False ' Add the radio button to the form. Controls.Add(radioButton1) End Sub
private void InitializeMyRadioButton() { // Create and initialize a new RadioButton. RadioButton radioButton1 = new RadioButton(); // Make the radio button control appear as a toggle button. radioButton1.Appearance = Appearance.Button; // Turn off the update of the display on the click of the control. radioButton1.AutoCheck = false; // Add the radio button to the form. Controls.Add(radioButton1); }
private void InitializeMyRadioButton() { // Create and initialize a new RadioButton. RadioButton radioButton1 = new RadioButton(); // Make the radio button control appear as a toggle button. radioButton1.set_Appearance(Appearance.Button); // Turn off the update of the display on the click of the control. radioButton1.set_AutoCheck(false); // Add the radio button to the form. get_Controls().Add(radioButton1); } //InitializeMyRadioButton

System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ButtonBase
System.Windows.Forms.RadioButton


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からRadioButton クラスを検索する場合は、下記のリンクをクリックしてください。

- RadioButton クラスのページへのリンク