设置CheckBoxList 选择框大小(记录)

 

1。aspx代码:

<head runat="server">
    <%=sb %>
</head>

<asp:CheckBoxList ID="chbList"  runat="server"></asp:CheckBoxList>


2。aspx.cs

protected StringBuilder sb = new StringBuilder();
        protected void Page_Load(object sender, EventArgs e)
        {   

            if (chbList.Items.Count > 0)
            {
                sb.AppendLine("<style type='text/css'>");
                for (int i = 0; i < chbList.Items.Count; i++)
                {
                    sb.AppendLine("#chbList_" + i + "{width:30px; height:30px;padding: 5 5 5 0;} ");
                }
                sb.AppendLine("</style>");
            }
        }

 

3。CheckBoxList生成的html,查找<input id="chbList_0"

<table id="chbList" class="STYLE2" cellspacing="5" cellpadding="5" border="0" style="zoom: 100%">
 <tr>
  <td><input id="chbList_0" type="checkbox" name="chbList$0" /><label for="chbList_0">aaaa</label></td>
 </tr><tr>
  <td><input id="chbList_1" type="checkbox" name="chbList$1" /><label for="chbList_1">BBBB</label></td>
 </tr><tr>
  <td><input id="chbList_2" type="checkbox" name="chbList$2" /><label for="chbList_2">CCCC</label></td>
 </tr><tr>
  <td><input id="chbList_3" type="checkbox" name="chbList$3" /><label for="chbList_3">DDDD</label></td>
 </tr><tr>
  <td><input id="chbList_4" type="checkbox" name="chbList$4" /><label for="chbList_4">EEEE</label></td>
 </tr>
</table>

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值