HtmlInputRadioButton イベント

名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。 ( Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。 ( Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。 ( Control から継承されます。) |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。 ( Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。 ( Control から継承されます。) |
![]() | ServerChange | HtmlInputRadioButton コントロールの Checked プロパティの値がサーバーへのポスト間で変更されるときに発生します。 |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。 ( Control から継承されます。) |

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


HtmlInputRadioButton コントロールを使用して、Web ページにオプション ボタンを作成します。HtmlInputRadioButton コントロールには、オプション ボタンのキャプションを表示する機能が組み込まれていません。キャプションを作成するには、Web ページの目的の位置でリテラル テキストを使用します。これにより、オプション ボタンのキャプションを表示する相対的な位置を確認できます。たとえば、オプション ボタンの右側にキャプションを表示する場合は、次のコードに示すように、HtmlInputRadioButton コントロールを宣言し、その後にキャプション テキストを続けます。
オプションで、Value プロパティを設定して、HtmlInputRadioButton コントロールに数量を関連付けることもできます。これは、複数のオプション ボタンがあって、選択内容に基づいて計算を実行する必要がある場合に役立ちます。
HtmlInputRadioButton コントロールを共にグループ化するには、グループに含める各オプション ボタンの Name プロパティに共通の値を指定します。
![]() |
---|
HtmlInputRadioButton コントロールを共にグループ化すると、グループ内では一度に 1 つのオプション ボタンしか選択できません。 |
HtmlInputRadioButton コントロールが選択されているかどうかを確認するには、Checked プロパティをテストします。HtmlInputRadioButton コントロールのグループがある場合は、コントロールを反復処理して、各コントロールの Checked プロパティを個別にテストする必要があります。
Checked プロパティの内容がサーバーへのポスト間で変更された場合は、HtmlInputRadioButton コントロールが提供する ServerChange イベントが発生します。これにより、イベントが発生したときにデータ検証などの特定の命令セットを実行するカスタム イベント ハンドラを作成できます。
HtmlInputRadioButton のインスタンスの初期プロパティ値の一覧については、HtmlInputRadioButton コンストラクタのトピックを参照してください。

HtmlInputRadioButton コントロールを使用してオプション ボタンのグループを作成する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script language="VB" runat="server"> Sub Button1_Click(sender As Object, e As EventArgs) If Radio1.Checked = True Then Span1.InnerHtml = "Option 1 is selected" Else If Radio2.Checked = True Then Span1.InnerHtml = "Option 2 is selected" Else If Radio3.Checked = True Then Span1.InnerHtml = "Option 3 is selected" End If End If End If End Sub 'Button1_Click </script> </head> <body> <form runat=server> <h3>HtmlInputRadioButton Sample</h3> <input type="radio" id="Radio1" name="Mode" runat="server"/> Option 1<br> <input type="radio" id="Radio2" name="Mode" runat="server"/> Option 2<br> <input type="radio" id="Radio3" name="Mode" runat="server"/> Option 3 <p> <span id="Span1" runat="server" /> <p> <input type="button" id="Button1" value="Enter" OnServerClick="Button1_Click" runat="server"> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat="server"> void Button1_Click(object sender, EventArgs e) { if (Radio1.Checked == true) Span1.InnerHtml = "Option 1 is selected"; else if (Radio2.Checked == true) Span1.InnerHtml = "Option 2 is selected"; else if (Radio3.Checked == true) Span1.InnerHtml = "Option 3 is selected"; } </script> </head> <body> <form runat=server> <h3>HtmlInputRadioButton Sample</h3> <input type="radio" id="Radio1" name="Mode" runat="server"/> Option 1<br> <input type="radio" id="Radio2" name="Mode" runat="server"/> Option 2<br> <input type="radio" id="Radio3" name="Mode" runat="server"/> Option 3 <p> <span id="Span1" runat="server" /> <p> <input type="button" id="Button1" value="Enter" OnServerClick="Button1_Click" runat="server"> </form> </body> </html>
<%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> <script language="JSCRIPT" runat="server"> function Button1_Click(sender : Object, e : EventArgs){ if(Radio1.Checked) Span1.InnerHtml = "Option 1 is selected" else if(Radio2.Checked) Span1.InnerHtml = "Option 2 is selected" else if(Radio3.Checked) Span1.InnerHtml = "Option 3 is selected" } </script> </head> <body> <form runat=server> <h3>HtmlInputRadioButton Sample</h3> <input type="radio" id="Radio1" name="Mode" runat="server"/> Option 1<br> <input type="radio" id="Radio2" name="Mode" runat="server"/> Option 2<br> <input type="radio" id="Radio3" name="Mode" runat="server"/> Option 3 <p> <span id="Span1" runat="server" /> <p> <input type="button" id="Button1" value="Enter" OnServerClick="Button1_Click" runat="server"> </form> </body> </html>


System.Web.UI.Control
System.Web.UI.HtmlControls.HtmlControl
System.Web.UI.HtmlControls.HtmlInputControl
System.Web.UI.HtmlControls.HtmlInputRadioButton


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


HtmlInputRadioButton コンストラクタ
アセンブリ: System.Web (system.web.dll 内)


このコンストラクタを使用して、HtmlInputRadioButton クラスの新しいインスタンスを作成し、初期化します。
HtmlInputRadioButton のインスタンスの初期プロパティ値を次の表に示します。

<%@ Page Language="VB" AutoEventWireup="True" %> <html> <script runat="server" > Sub Page_Load(sender As Object, e As EventArgs) If Not IsPostBack Then ' Create the first HtmlInputRadioButton control. Dim radio1 As HtmlInputRadioButton = New HtmlInputRadioButton() radio1.Value = "Value1" radio1.Checked = True radio1.Name = "RadioSet" ' Create the caption for the first HtmlInputRadioButton control. Dim span1 As HtmlGenericControl = New HtmlGenericControl("span") span1.InnerHtml = "Radio Button 1 <br>" ' Add the controls to the Controls collection of the ' PlaceHolder control. Place.Controls.Clear() Place.Controls.Add(radio1) Place.Controls.Add(span1) ' Create the second HtmlInputRadioButton control. Dim radio2 As HtmlInputRadioButton = New HtmlInputRadioButton() radio2.Value = "Value2" radio2.Checked = False radio2.Name = "RadioSet" ' Create the caption for the second HtmlInputRadioButton control. Dim span2 As HtmlGenericControl = New HtmlGenericControl("span") span2.InnerHtml = "Radio Button 2 <br>" ' Add the control to the Controls collection of the ' PlaceHolder control. Place.Controls.Add(radio2) Place.Controls.Add(span2) End If End Sub </script> <body> <form runat="server"> <h3> HtmlInputRadioButton Constructor Example </h3> <asp:PlaceHolder id="Place" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <script runat="server" > void Page_Load(Object sender, EventArgs e) { if(!IsPostBack) { // Create the first HtmlInputRadioButton control. HtmlInputRadioButton radio1 = new HtmlInputRadioButton(); radio1.Value = "Value1"; radio1.Checked = true; radio1.Name = "RadioSet"; // Create the caption for the first HtmlInputRadioButton control. HtmlGenericControl span1 = new HtmlGenericControl("span"); span1.InnerHtml = "Radio Button 1 <br>"; // Add the controls to the Controls collection of the // PlaceHolder control. Place.Controls.Clear(); Place.Controls.Add(radio1); Place.Controls.Add(span1); // Create the second HtmlInputRadioButton control. HtmlInputRadioButton radio2 = new HtmlInputRadioButton(); radio2.Value = "Value2"; radio2.Checked = false; radio2.Name = "RadioSet"; // Create the caption for the second HtmlInputRadioButton control. HtmlGenericControl span2 = new HtmlGenericControl("span"); span2.InnerHtml = "Radio Button 2 <br>"; // Add the control to the Controls collection of the // PlaceHolder control. Place.Controls.Add(radio2); Place.Controls.Add(span2); } } </script> <body> <form runat="server"> <h3> HtmlInputRadioButton Constructor Example </h3> <asp:PlaceHolder id="Place" runat="server"/> </form> </body> </html>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


HtmlInputRadioButton プロパティ



HtmlInputRadioButton メソッド



名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IPostBackDataHandler.LoadPostData | LoadPostData メソッドを呼び出すことにより、IPostBackDataHandler.LoadPostData メソッドを実装します。 |
![]() | System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent | RaisePostDataChangedEvent メソッドを呼び出すことにより、IPostBackDataHandler.RaisePostDataChangedEvent メソッドを実装します。 |

HtmlInputRadioButton メンバ
サーバー上の HTML <input type= radio> 要素にプログラムによってアクセスできるようにします。
HtmlInputRadioButton データ型で公開されるメンバを以下の表に示します。






名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。(Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。(Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。(Control から継承されます。) |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。(Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。(Control から継承されます。) |
![]() | ServerChange | HtmlInputRadioButton コントロールの Checked プロパティの値がサーバーへのポスト間で変更されるときに発生します。 |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。(Control から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IPostBackDataHandler.LoadPostData | LoadPostData メソッドを呼び出すことにより、IPostBackDataHandler.LoadPostData メソッドを実装します。 |
![]() | System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent | RaisePostDataChangedEvent メソッドを呼び出すことにより、IPostBackDataHandler.RaisePostDataChangedEvent メソッドを実装します。 |

- HtmlInputRadioButtonのページへのリンク