ASP.NET中 RadioButtonList 單選按鈕組控件的使用方法
來(lái)源:易賢網(wǎng) 閱讀:1683 次 日期:2016-08-09 15:23:48
溫馨提示:易賢網(wǎng)小編為您整理了“ASP.NET中 RadioButtonList 單選按鈕組控件的使用方法”,方便廣大網(wǎng)友查閱!

本文主要簡(jiǎn)單介紹RadioButtonList控件的常見(jiàn)屬性和使用方法,希望對(duì)大家有所幫助。

RadioButtonList 控件表示一個(gè)封裝了一組單選按鈕控件的列表控件。

可以使用兩種類型的 ASP.NET 控件將單選按鈕添加到網(wǎng)頁(yè)上:各個(gè) RadioButton 控件或一個(gè) RadioButtonList 控件。這兩類控件都允許用戶從一小組互相排斥的預(yù)定義選項(xiàng)中進(jìn)行選擇。使用這些控件,可定義任意數(shù)目的帶標(biāo)簽的單選按鈕,并將它們水平或垂直排列。

一、常用屬性

屬性 作用
Repeatdirection Horizontal|Vertical 項(xiàng)的布局方向:水平方向|豎直風(fēng)向
RepeatLayout table|Flow 展現(xiàn)方式:表格|流線型
Selected true|Falsee 是否為選中狀態(tài)

二、代碼演示

前臺(tái) RadioButtonList.aspx

代碼如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadioButtonList.aspx.cs" Inherits="WebControls_RadioButtonList" %>

<!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 runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <h3>RadioButtonList(單選按鈕組)</h3>

        <hr />

        請(qǐng)選擇性別:<asp:RadioButtonList 

            ID="radlSex" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">

            <asp:ListItem Selected="True">男</asp:ListItem>

            <asp:ListItem>女</asp:ListItem>

        </asp:RadioButtonList>

        <br />

        <asp:Button ID="btnSubmit" runat="server" Text="提交" onclick="btnSubmit_Click" />

        <hr />

        你選擇的性別為:<asp:Label ID="lblState" runat="server"></asp:Label>

    </div>

    </form>

</body>

</html>

后臺(tái) RadioButtonList.aspx.cs

代碼如下:

using System;

using System.Collections.Generic;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

public partial class WebControls_RadioButtonList : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

    }

    protected void btnSubmit_Click(object sender, EventArgs e)

    {

        lblState.Text = radlSex.SelectedValue;

    }

}

更多信息請(qǐng)查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機(jī)網(wǎng)站地址:ASP.NET中 RadioButtonList 單選按鈕組控件的使用方法
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65317125(9:00—18:00) 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)