Go homepage(回首页) Upload pictures (上传图片) Write articles (发文字帖)
The author:(作者)qqpublished in(发表于) 2014/7/9 1:37:50 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控件常用事件。
赞