zoukankan      html  css  js  c++  java
  • 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{100%;height:auto;}
    .rblStyle input{border-style:none;}


    3.onselectedindexchanged事件

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

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

  • 相关阅读:
    P2426 删数
    P2115 [USACO14MAR]破坏Sabotage
    P2679 子串
    P2979 [USACO10JAN]奶酪塔Cheese Towers
    P1114 “非常男女”计划
    P2105 K皇后
    P4053 [JSOI2007]建筑抢修
    P1294 高手去散步
    P4316 绿豆蛙的归宿
    P2253 好一个一中腰鼓!
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/3947717.html
Copyright © 2011-2022 走看看