Home How to keep URL's parameters with Html.PagedListPager
Reply: 1

How to keep URL's parameters with Html.PagedListPager

Arif YILMAZ Published in 2018-02-10 20:31:44Z

I am new Html.PagedListPager and trying to use it in my project. It seems very usefull but I have a problem to solve.

when I use code below, everything works as expected. But when I click one of the page number with the below code, It clears all URL parameters.

@Html.PagedListPager(Model, Page=> Url.Action("Products", new { Page,  sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }), PagedListRenderOptions.ClassicPlusFirstAndLast)

When I click one of the pages, I lose Category and Brand values from the URL


this url gets changed to


How can I keep the Brand and Category values? Thanks in advance

Amr Reply to 2018-02-11 17:37:52Z
@Html.PagedListPager(Model, page => Url.Action("Products",
                            new { page, sortOrder = ViewBag.CurrentSort,  Category = ViewBag.Category, Brand = ViewBag.Brand }))

And in controller action :

 public ActionResult Products(string SortOrder, string Category,sting Brand, int? Page)
            ViewBag.CurrentSort = SortOrder;
            ViewBag.Category= Category;
            ViewBag.Brand= Brand;
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.327097 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO