ASP.NET中 RadioButtonList 单选按钮组控件的使用方法
RadioButtonList控件表示一个封装了一组单选按钮控件的列表控件。
可以使用两种类型的ASP.NET控件将单选按钮添加到网页上:各个RadioButton控件或一个RadioButtonList控件。这两类控件都允许用户从一小组互相排斥的预定义选项中进行选择。使用这些控件,可定义任意数目的带标签的单选按钮,并将它们水平或垂直排列。
一、常用属性
二、代码演示
前台RadioButtonList.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="RadioButtonList.aspx.cs"Inherits="WebControls_RadioButtonList"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<div>
<h3>RadioButtonList(单选按钮组)</h3>
<hr/>
请选择性别:<asp:RadioButtonList
ID="radlSex"runat="server"RepeatDirection="Horizontal"RepeatLayout="Flow">
<asp:ListItemSelected="True">男</asp:ListItem>
<asp:ListItem>女</asp:ListItem>
</asp:RadioButtonList>
<br/>
<asp:ButtonID="btnSubmit"runat="server"Text="提交"onclick="btnSubmit_Click"/>
<hr/>
你选择的性别为:<asp:LabelID="lblState"runat="server"></asp:Label>
</div>
</form>
</body>
</html>
后台RadioButtonList.aspx.cs
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
publicpartialclassWebControls_RadioButtonList:System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
}
protectedvoidbtnSubmit_Click(objectsender,EventArgse)
{
lblState.Text=radlSex.SelectedValue;
}
}
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短