オプション ボタンが属するグループの名前を取得または設定します。
名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文
'宣言
<ThemeableAttribute(False)> _
Public Overridable Property GroupName As String
'使用
Dim instance As RadioButton
Dim value As String
value = instance.GroupName
instance.GroupName = value
[ThemeableAttribute(false)]
public virtual string GroupName { get; set; }
[ThemeableAttribute(false)]
public:
virtual property String^ GroupName {
String^ get ();
void set (String^ value);
}
/** @property */
public String get_GroupName ()
/** @property */
public void set_GroupName (String value)
public function get GroupName () : String
public function set GroupName (value : String)
適用できません。
プロパティ値
オプション ボタンが属するグループの名前。既定値は空の文字列 ("") です。
解説
GroupName プロパティを使用して、オプション ボタンのグループを指定し、同時に選択できない複数のコントロールのセットを作成します。GroupName プロパティは、利用できるオプションのリストから項目を 1 つだけ選択できる場合に使用します。
このプロパティを設定した場合は、一度に選択できるのは、指定されたグループの 1 つの RadioButton だけです。
このプロパティの値はビューステートに格納されます。
このプロパティは、テーマまたはスタイル シート テーマによって設定することはできません。詳細については、ThemeableAttribute、ASP.NET のテーマとスキンの概要 の各トピックを参照してください。
トピック | 場所 |
---|---|
方法 : Web フォーム ページに RadioButton Web サーバー コントロールを追加する (Visual Studio) | Visual Studio での ASP .NET Web アプリケーションの作成 |
方法 : Web フォーム ページに RadioButton Web サーバー コントロールを追加する | Visual Studio ASP .NET での Web アプリケーションの作成 |
方法 : Web フォーム ページに RadioButton Web サーバー コントロールを追加する | Visual Studio ASP .NET での Web アプリケーションの作成 |
方法 : 各 RadioButton Web サーバー コントロールを Web フォーム ページに追加する | ASP .NET Web アプリケーションの作成 |
使用例
GroupName プロパティをプログラムによって設定する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Panel Example</title>
<script language="VB" runat="server">
Sub Button1_Click(sender As Object, e As EventArgs)
If Radio3.GroupName = "RegularMenu" Then
Radio3.GroupName = "vegetarianMenu"
Radio3.BackColor = System.Drawing.Color.LightGreen
Else
Radio3.GroupName = "RegularMenu"
Radio3.BackColor = System.Drawing.Color.Pink
End If
End Sub
</script>
</head>
<body>
<h3>Panel Example</h3>
<form id="form1" runat="server">
<asp:Label id="Label1" BackColor="Pink" Text="RegularMenu" runat="server"/>
<asp:Label id="Label2" BackColor="LightGreen" Text="vegetarianMenu" runat="server"/>
<br />
<asp:RadioButton id="Radio1" GroupName="RegularMenu"
Text="Beef" BackColor="Pink" runat="server"/>
<br />
<asp:RadioButton id="Radio2" GroupName="RegularMenu"
Text="Pork" BackColor="Pink" runat="server"/>
<br />
<asp:RadioButton id="Radio3" GroupName="RegularMenu"
Text="Fish" BackColor="Pink" runat="server"/>
<br />
<asp:RadioButton id="Radio4" GroupName="vegetarianMenu"
Text="Mushroom" BackColor="LightGreen" runat="server"/>
<br />
<asp:RadioButton id="Radio5" GroupName="vegetarianMenu"
Text="Tofu" BackColor="LightGreen" runat="server"/>
<br />
<asp:Button id="Button1" OnClick="Button1_Click"
Text="Regroup the radio buttons" runat="server"/>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Panel Example</title>
<script language="C#" runat="server">
void Button1_Click(Object sender, EventArgs e) {
if (Radio3.GroupName == "RegularMenu") {
Radio3.GroupName = "vegetarianMenu";
Radio3.BackColor = System.Drawing.Color.LightGreen;
}
else {
Radio3.GroupName = "RegularMenu";
Radio3.BackColor = System.Drawing.Color.Pink;
}
}
</script>
</head>
<body>
<h3>Panel Example</h3>
<form id="form1" runat="server">
<asp:Label id="Label1" BackColor="Pink" Text="RegularMenu" runat="server"/>
<asp:Label id="Label2" BackColor="LightGreen" Text="vegetarianMenu" runat="server"/>
<br />
<asp:RadioButton id="Radio1" GroupName="RegularMenu"
Text="Beef" BackColor="Pink" runat="server"/>
<br />
<asp:RadioButton id="Radio2" GroupName="RegularMenu"
Text="Pork" BackColor="Pink" runat="server"/>
<br />
<asp:RadioButton id="Radio3" GroupName="RegularMenu"
Text="Fish" BackColor="Pink" runat="server"/>
<br />
<asp:RadioButton id="Radio4" GroupName="vegetarianMenu"
Text="Mushroom" BackColor="LightGreen" runat="server"/>
<br />
<asp:RadioButton id="Radio5" GroupName="vegetarianMenu"
Text="Tofu" BackColor="LightGreen" runat="server"/>
<br />
<asp:Button id="Button1" OnClick="Button1_Click"
Text="Regroup the radio buttons" runat="server"/>
</form>
</body>
</html>
<%@ Page Language="JScript" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Panel Example</title>
<script language="JScript" runat="server">
function Button1_Click(sender, e : EventArgs) {
if (Radio3.GroupName == "RegularMenu") {
Radio3.GroupName = "vegetarianMenu";
Radio3.BackColor = System.Drawing.Color.LightGreen;
}
else {
Radio3.GroupName = "RegularMenu";
Radio3.BackColor = System.Drawing.Color.Pink;
}
}
</script>
</head>
<body>
<h3>Panel Example</h3>
<form id="form1" runat="server">
<asp:Label id="Label1" BackColor="Pink" Text="RegularMenu" runat="server"/>
<asp:Label id="Label2" BackColor="LightGreen" Text="vegetarianMenu" runat="server"/>
<br />
<asp:RadioButton id="Radio1" GroupName="RegularMenu"
Text="Beef" BackColor="Pink" runat="server"/>
<br />
<asp:RadioButton id="Radio2" GroupName="RegularMenu"
Text="Pork" BackColor="Pink" runat="server"/>
<br />
<asp:RadioButton id="Radio3" GroupName="RegularMenu"
Text="Fish" BackColor="Pink" runat="server"/>
<br />
<asp:RadioButton id="Radio4" GroupName="vegetarianMenu"
Text="Mushroom" BackColor="LightGreen" runat="server"/>
<br />
<asp:RadioButton id="Radio5" GroupName="vegetarianMenu"
Text="Tofu" BackColor="LightGreen" runat="server"/>
<br />
<asp:Button id="Button1" OnClick="Button1_Click"
Text="Regroup the radio buttons" runat="server"/>
</form>
</body>
</html>
プラットフォーム
Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
参照
関連項目
RadioButton クラス
RadioButton メンバ
System.Web.UI.WebControls 名前空間
その他の技術情報
RadioButton Web サーバー コントロールおよび RadioButtonList Web サーバー コントロール