开发者

Hide Checkbox Icon for a ListItem in checkboxlist

Is there a way to hide the checkbox icon for an ListItem and just display the value-text.

Like Below - Checkbox for items is hidden.

I could figure out that I could disable (grey-out) or completely hide (invisible) a list item but not just hide the checkbox icon (square)

开发者_如何学C

Hide Checkbox Icon for a ListItem in checkboxlist


I recently did this as part of a project and accomplished it via setting an attribute when creating the ListItem and then using CSS to style it.

li.Attributes.Add("id", "removecheckbox");

Since the attribute is added as part of a tag, you can use the following descriptor in your CSS.

#removecheckbox
{
    color: Gray;
}
#removecheckbox input
{
    display: none;
}

Of course, you can format the CSS any way you'd like, but this should get you started. If you'd like more information using selectors in CSS, check out this reference from w3.org.

HTH!


CSS3 will help you, define Inline style, good point is to make special UserControl for CheckBoxList to use following solution

<style>
    input:disabled {
        display: none;
    }
</style>

and in CheckBoxList PreRender event disable ListItem to apply CSS input:disabled selector

protected void CheckBoxListMajad_PreRender(object sender, EventArgs e)
{
    foreach (ListItem it in this.CheckBoxListMajad.Items)
    {
        if (it.Value.Equals("0"))
        {
            it.Enabled = false;
            it.Selected = false;
            it.Attributes.Add("style", "font-size:14px;height:16px;font-weight:bold;");
        }
    }
}

CheckBoxListMajad.RepeatColumn=3

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜