AnotherGeek
AnotherGeek

Reputation: 904

customize Html.Pager genereted url

I am trying to add pagination to a page with Html.Pager of the MvcPaging, the problem is that the url generated contains the page number in a value named page. So I got something like this /orders?page=1 I want it to be like this /orders?pageIndex=1

here is my code

@Html.Pager(Model.PageSize, Model.CurrentPage, Model.TotalPage * Model.PageSize).Options(o => o.DisplayTemplate("_paginationFooter"));

Upvotes: 0

Views: 1091

Answers (1)

user3559349
user3559349

Reputation:

Use the PageRouteValueKey property of Options to override the default value (which is "page")

@Html.Pager(Model.PageSize, Model.CurrentPage, Model.TotalPage * Model.PageSize).Options(o => o
    .PageRouteValueKey("pageIndex")
    .DisplayTemplate("_paginationFooter")
)

For a complete list of all options (and the source code), refer MvcPaging.

Upvotes: 1

Related Questions