Customize ASP.Net DataPager generated HTML

前端 未结 2 381
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 16:29

I am using a ListView and DataPager in my web project for pagination. It works fine, but the generated HTML for the pagination is simply a span containing some hyperlinks.

2条回答
  •  一个人的身影
    2021-01-05 17:25

    use jQuery or JavaScript: the datapager renders links with   between them so get the rendered html and split it at   then create your ul and append the items as li.

     $(function() {
            var pagerControl = <%= "'#" & DataPager1.ClientId & "';" %>
            $(pagerControl).hide(); 
             var items = $(pagerControl).html().split(' ');
             $.each(items, function(index, value) { if (value.length > 0)$('#pagination').append('
  • ' + value + '
  • '); }); });

提交回复
热议问题