@634

ASP.NET - WEBフォームコントロール - asp:RadioButtonList

Advertisement

用途

asp:RadioButtonListコントロールを使用すると、ラジオボタンの集合を一度に定義することができる。

書式

<asp:RadioButtonList
    id="CheckBoxList01"
    TextAlign="テキスト位置"
    RepeatLayout="レイアウト"
    RepeatColumns="列数"
    RepeatDirection="整列方向"
    runat="server">
    <asp:ListItem Value="値">テキスト</asp:ListItem>
</asp:RadioButtonList>
※上記の属性以外にも、見栄えの定義などの属性があります。

入れ子になっているasp:ListItemが実際のラジオボタンになる。

TextAlign
RightまたはLeftのどちらかを指定。Rightの場合、ラジオボタンの右側に文字列が表示され、Leftの場合はラジオボタンの左側に文字列が表示される。

RepeatLayout
TableかFlowを指定する。Tableを指定すると<table>タグを使用したコードが出力される。Flowの場合はspanタグを使用したコードが出力される。

RepeatColumns
列数を指定する。これにより、n列m行のグループを作成できるので柔軟なレイアウトを行うことができる。

RepeatDirection
HorizontalかVerticalのどちらかを指定する。Horizontalを指定するとラジオボタン群の整列される方向が横になり、Verticalの場合は縦になる。

サンプル

サンプルコード
<form runat="server">
<asp:RadioButtonList
    id="CheckBoxList01"
    TextAlign="Right"
    RepeatLayout="Flow"
    RepeatColumns="2"
    RepeatDirection="Horizontal"
    runat="server">
      <asp:ListItem Value="少年">少年</asp:ListItem>
      <asp:ListItem Value="中年">中年</asp:ListItem>
      <asp:ListItem Value="老人">老人</asp:ListItem>
      <asp:ListItem Value="その他">その他</asp:ListItem>
</asp:RadioButtonList>
</form>

実行イメージ


イベント

SelectedIndexChanged

Advertisement

ショートカット

634トップページ
このカテゴリのトップページに戻る
634ラボ
   UIコレクションギャラリー

サイト検索

Google

Web サイト内

Y!ログール