Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@Html.PagedListPager add a CSS class

I have just made a perfect paged list in MVC 5. On each PagedListPager I want to add a CSS class:

@Html.PagedListPager(Model, page => Url.Action("Toetsstart",
    new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))

How can I do this?

like image 949
Sander Dongelmans Avatar asked Oct 07 '16 07:10

Sander Dongelmans


1 Answers

Adding classes can be done in the PagedListRenderOptions like so:

@Html.PagedListPager(
    model,
    page => Url.Action("Index",
    new
    {
        page,
        sortOrder = ViewBag.CurrentSort,
        currentFilter = viewBag.CurrentFilter
    }
    ),
    new PagedListRenderOptions()
    {
        LiElementClasses = new List<string> {"myClass", "yourClass"}
    })  

There are a number of places you can put classes, including:

LiElementClasses
ClassToApplyToFirstListItemInPager
ClassToApplyToLastListItemInPager
ContainerDivClasses
UlElementClasses
like image 126
Barry Franklin Avatar answered Sep 20 '22 08:09

Barry Franklin