Applying Styles To ListItems in CheckBoxList

前端 未结 6 1595
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 14:15

How can styles be applied to CheckBoxList ListItems. Unlike other controls, such as the Repeater where you can specify , you can\'t seem to sp

6条回答
  •  野性不改
    2020-11-28 14:50

    In addition to Andrew's answer...

    Depending on what other attributes you put on a CheckBoxList or RadioButtonList, or whatever, ASP.Net will render the output using different structures. For example, if you set RepeatLayout="Flow", it won't render as a TABLE, so you have to be careful of what descendant selectors you use in your CSS file.

    In most cases, you can can just do a "View Source" on your rendered page, maybe on a couple of different browsers, and figure out what ASP.Net is doing. There is a danger, though, that new versions of the server controls or different browsers will render them differently.

    If you want to style a particular list item or set of list items differently without adding in attributes in the code-behind, you can use CSS attribute selectors. The only drawback to that is that they aren't supported in IE6. jQuery fully supports CSS 3 style attribute selectors, so you could probably also use it for wider browser support.

提交回复
热议问题