开发者

can we use different images for asp.net bulleted list control ? if yes then how?

i am using asp.net bulleted list control i can use images by setting the imageURL property of bulleted list but this will reflect on all list items that belongs to that Bulleted list. What if i want to use different images for each 开发者_Python百科list items.


Add some classes to represent your different list images:

CSS:

ul { list-style-type: none; }
.bullet1 { list-style-image: url("images/list_bullet.jpg")}
.bullet2 { list-style-image: url("images/list_bullet2.jpg")}

In your HTML, set each list item to the class that will display the image.

HTML:

<ul>
  <li class="bullet1"><span>item 1</span></li>
  <li class="bullet2"><span>item 2</span></li>
</ul>

I've not used the BulletedList control, but you should be able to set the CSSClass attribute on each indidual list item, either directly in the markup or in one of the databinding events (if your list is databound).

You can also use JQuery to manipulate your lists after the page has been rendered. For example, this script sets every other list item to a different image:

<script type="text/javascript">
    $(document).ready(function () {
        $('#list li').each(function (index) {
            var imgClass = index % 2 == 0 ? 'bullet1' : 'bullet2';
            $(this).addClass(imgClass);
        })
    });
</script>


How about using Repeater control for customized bulleted list? see this answer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜