checkboxlist的布局问题

本文介绍如何使用CSS为ASP.NET中的CheckBoxList控件设置样式,并通过JavaScript获取已选择的值。具体包括如何定义列数、布局方向及内边距等属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

css样式:
<style type="text/css">
#cbxListParent input {vertical-align:middle;float:left;}
#cbxListQuestionType input{vertical-align:middle;}
.cb td{width:100px;} 
.cb label{display:inline-block;width:80px;}
</style>
 
<asp:CheckBoxList ID="cbxListQuestionType"
runat="server"
CssClass="cb"                                                                        //这里是css
RepeatLayout="Table"                                                           //排列方式(table,ol之类)
RepeatColumns="4"                                                               //每行几列  (4列)
RepeatDirection="Horizontal"                                                 //布局方式(纵向【默认】、横向)这里是横向

CellPadding="5" CellSpacing="5" Width="400"></asp:CheckBoxList>




<asp:CheckBoxList ID="DDLGroups" runat="server" RepeatLayout="Table" RepeatColumns="2" RepeatDirection="Horizontal" style="border-collapse:collapse; line-height:18px;margin-left:2px;">  
                                            </asp:CheckBoxList>  




[css] 
<style type="text/css">  
    #DDLGroups{border-collapse:collapse; line-height:18px}  
   #DDLGroups td{width:300px; border:1px solid #F0F8FF;padding-left:5px}  
      
    </style>  


获取所选值:


[javascript]
//获取联系人组  
        $("#DDLGroups tbody tr td input:checkbox:checked").each(function () {  
           alert($(this).parent().find("label").html())  
        });

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值