Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pauldotknopf/paginglinksbuilder

A single .cs file for you to add to your project. It quickly adds a very configurable paging control to your project. It renders out-of-the-box Twitter Bootstrap fiendly too!
https://github.com/pauldotknopf/paginglinksbuilder

Last synced: 17 days ago
JSON representation

A single .cs file for you to add to your project. It quickly adds a very configurable paging control to your project. It renders out-of-the-box Twitter Bootstrap fiendly too!

Awesome Lists containing this project

README

        

PagingLinksBuilder.cs
==================

A single .cs file for you to add to your project. It quickly adds a very configurable paging control to your project. It renders out-of-the-box Twitter Bootstrap fiendly too!

![PagingLinksBuidler preview](https://raw.github.com/theonlylawislove/PagingLinksBuilder/master/preview.jpg)

# Getting Started

Add [the only file](https://raw.github.com/theonlylawislove/PagingLinksBuilder/master/PagingLinksBuilder.cs) you need to your project.

Add the following to an HtmlHelper extension method somewhere.

```c#
public static PagingLinksBuilder PagingLinksBuilder
(this HtmlHelper helper,
int currentPage,
int totalPages,
Func pageUrlBuilder)
{
return new PagingLinksBuilder(currentPage, totalPages, pageUrlBuilder);
}
```

Then use the following in your views.

```c#
@Html.PagingLinksBuilder(1, 10, (page) => "/somewhere?p=" + page)
```

You are ready to rock-n-roll!

#Configuration/Defaults

The following represents a complete configuration of the defaults.

```c#
@(Html.PagingLinksBuilder(1, 10, (page) => "/somewhere?p=" + page)
.LayoutTemplate(
@

)
.ItemTemplate(
@
  • @item.LinkRender
  • )
    .LinkTemplate(
    @@item.LinkText)
    .MaxNumberOfTrailingLeadingPages(2)
    .AlwaysShowNavigation(true)
    .FirstCssClass("first")
    .PreviousCssClass("previous")
    .NextCssClass("next")
    .LastCssClass("last")
    .PageCssClass("page")
    .DisabledCssClass("disabled")
    .ActiveCssClass("active"))
    ```

    Enjoy!