次の方法で共有


HtmlInputRadioButton コンストラクタ

HtmlInputRadioButton クラスの新しいインスタンスを初期化します。

Public Sub New()
[C#]
public HtmlInputRadioButton();
[C++]
public: HtmlInputRadioButton();
[JScript]
public function HtmlInputRadioButton();

解説

このコンストラクタを使用して、 HtmlInputRadioButton クラスの新しいインスタンスを作成し、初期化します。

HtmlInputRadioButton のインスタンスの初期プロパティ値を次の表に示します。

プロパティ 初期値
TagName "radio" リテラル文字列。

使用例

 
<%@ 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>
 

[C#] 
<%@ 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>
 

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

HtmlInputRadioButton クラス | HtmlInputRadioButton メンバ | System.Web.UI.HtmlControls 名前空間