RadioButtonList的使用

概述:

RadioButtonList 控件为网页开发者提供了一组单选button,这些button能够通过数据绑定动态生成。该控件包括一个items集合,集合中的成员与列表中的各项相相应。

                <div class="rblStyle">
                <asp:RadioButtonList ID="rblChangQHT" runat="server" RepeatDirection="Horizontal">
                <asp:ListItem Text="是" Value="1"></asp:ListItem>
                <asp:ListItem Text="否" Value="0"></asp:ListItem>
                </asp:RadioButtonList></div>

1.RadioButtonList的校验

            var rb_ChangQHT = document.getElementById("rblChangQHT");
            var ShiF = rb_ChangQHT.getElementsByTagName("INPUT");
            var result = false;
            for (var i = 0; i < ShiF.length; i++) {
                if (ShiF[i].checked) {
                    result = true;
                    break;
                }
            }
            if (!result) {
                alert("是否为中长期合同为必填项!");
                return false;
            }

2.RadioButtonList的样式调整

(1)去掉难看的单选边框

为RadioButtonList控件加入<div>层,并为div设置样式

.rblStyle{width:100%;height:auto;}
.rblStyle input{border-style:none;}

3.onselectedindexchanged事件

像下拉控件dropdownlist控件一样,它也有onselectedindexchanged事件,当选项改变后进行触发

注意点是:控件中的AutoPostBack属性一定设为"True",这样server端才知道你的选项改变了,并触发对应事件

时间: 2024-08-25 22:54:45

RadioButtonList的使用的相关文章

标准控件(六)——RadioButton,RadioButtonList

RadioButton 单选按钮 拥有Label的所有属性. Text                    文本 Checked                 bool,是否被选中 GroupName               组名,将来被呈现为<input type=radio>中的name属性 RadioButtonList 显示多个,选择1个.布局. 属性 Items DataSource              数据源 DataTextField           显示的内容

给RadioButtonList绑定Selected的值

有一个案例,是读取Excel的资料显示于ASP.NET的GridView控件.在GridView控件中,有一列是用RadioButtonList来显示性别信息(男或女). 另外来看看Excel的数据: 接下来,看看显示: 后台为这个RadioButtonList控件绑定数据: 浏览看结果: 看到否,性别一列中全没有相对应选中,如在Excel中某一笔记录性别是女,那显示于在GridView的性别中,女选项是选中状态.下面想法办法把它解决.在RadioButtonList绑定完数据源之后,再对数据进

RadioButtonList 和CheckBoxList根据后天数据库的值加载时选中其选项

前台: <x:RadioButtonList ID="rbSex" Label="性别" runat="server"  >                                       <x:RadioItem Text="男" Value="男" Selected="true"  />                               

.net中单选按钮RadioButton,RadioButtonList 以及纯Html中radio的用法实例?

http://www.cnblogs.com/summers/archive/2013/07/31/3227234.html .net中单选按钮RadioButton,RadioButtonList 以及纯Html中radio的用法,区别? RadioButton实例及说明: <asp:RadioButton ID="publicHas" Checked="true" runat="server" CssClass="radioM

RadioButtonList控件

在这里只写,绑定数据库数据的RadioButtonList控件: 一: 首先,先在数据库中建立一张表: 1 CREATE TABLE KK 2 ( 3 id INT, 4 [name] VARCHAR(20), 5 ) 然后插入数据: 1 INSERT INTO KK (id, [name]) VALUES (1, '张三') 2 INSERT INTO KK (id, [name]) VALUES (2, '李四') 3 INSERT INTO KK (id, [name]) VALUES (

DropDownList的使用,RadioButtonList的使用

DropDownList的使用之从后台动态获取值 前端aspx代码如下 <asp:DropDownList ID="DDLTypeID" runat="server" > </asp:DropDownList> 后台cs代码 private void DDLTypeIDBind() { DDLTypeID.DataSource = DBSqlHelper.getDataTable("select * from 表名 ");

Jquery 操作RadioButtonList,DropDownList

Jquery版本2.1.4 RadioButtonList 1.获取值: $("input[name='rbtn']:checked").val(); 2.设置值 $("input[name='rbtn']:checked").val(val); 其中val为值 DropDownList 1.获取值: $("#ddl").val(); 2.设置值: $("#ddl").find("option[value='val'

RadioButtonList选择事件onclick

<asp:RadioButtonList ID="rbtnFInvoiceType" runat="server" onclick="checkType()" RepeatDirection="Horizontal"> <asp:ListItem Selected="True">收据</asp:ListItem> <asp:ListItem>发票</as

.net控件Radiobuttonlist的简单应用

1.radiobuttonlist 通过RepeatDirection属性控制改控件的显示方向是纵向还是横向. 2.radiobuttonlist有一个重要的时间叫OnSelectedIndexChanged事件,该事件必须配合着属性AutoPostBack使用. 3.应用: 首先可以将前台代码上面的一些控件隐藏,这种隐藏的属性必须是visiable的隐藏(style中的隐藏不好用,后台无法控制,也可能style中的隐藏在后台需要另一种方法来控制) 通过Radiobuttonlist中的OnSe

用户控件 RadioButtonList

public static MvcHtmlString RadioButtonList(this HtmlHelper htmlHelper, string name, string codeCategory, RepeatDirection repeatDirection = RepeatDirection.Horizontal) { var codes = CodeManager.GetCodes(codeCategory); return ListControlUtil.GenerateH