Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)qq
published in(发表于) 2014/7/9 1:37:50
asp.net2.0服务器控件之RadioButton控件

asp.net2.0服务器控件之RadioButton控件

RadioButton控件

1.功能

RadioButton控件是一种单选按钮控件,允许用户从给出的选项集中仅选出一个选项。通过为所有的单选按钮分配相同的GroupName,强制执行该限制条件。

2.属性

RadioButton控件常用属性及描述如表1所示。



表1 RadioButton控件常用属性及描述

使用GroupName属性指定一组单选按钮,以创建一组互相排斥的控件。当只能从可用选项列表中选择一项时,可使用GroupName属性。设置该属性后,每次只能使该组中的一个 RadioButton为选中状态。

例如,在网页上添加一个RadioButton控件,ID属性分别设为rbtnSex1和rbtnSex2,Text属性分别设为“男”和“女”。由于对性别的选择,只能选择一项,故将这两个RadioButton按钮的GroupName设置为同一个。代码如下:

//设置RadioButton控件显示的文本

this.rbtnSex1.Text = "男";

this.rbtnSex2.Text = "女";

//设置RadioButton控件所属的组

this.rbtnSex1.GroupName = "Sex";

this.rbtnSex2.GroupName = "Sex";

运行结果如图1所示



图1 RadioButton控件的运行结果图

3.方法

交叉链接:RadioButton控件常用方法同Label控件类似,可参见Label控件常用方法。

4.事件

交叉链接:RadioButton控件常用事件同CheckBox控件类似,可参见CheckBox控件常用事件。




If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759