Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8110499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:46:40+00:00 2026-06-06T01:46:40+00:00

I’m not using a Grid, just using the MvcContrib Pager. I have a partial

  • 0

I’m not using a Grid, just using the MvcContrib Pager. I have a partial view created for the Pager (so I can display it at top and bottom of the results easily), and it calls the @Html. Pager method as so:

 @Html.Pager(Model.PagedPrograms).First("<<").Last(">>").Next(">").Previous("<").Format("Item {0} - {1} of {2} ")

This works without additional tweaking as long as all parameters are passed to the page via QueryString, since Pager knows to rebuild those back on the URLs.

I’d like to give the user the option to change the page size (say 20, 50, All) … I can easily handle that on the controller end, and I could write something like

@if (Model is Foo) {
     @Html.ActionLink<SearchController>(sc => sc.Foo(var1, var2, var3, 20), "20")
     @Html.ActionLink<SearchController>(sc => sc.Foo(var1, var2, var3, 50), "50");
     @Html.ActionLink<SearchController>(sc => sc.Foo(var1, var2, var3, -1), "All");
}

But I would have to do that for each Model type that might use this Pager… I might be overthinking this or coming at this completely backwards, but I thought I’d ask and see if anyone had insight.

Currently the Pager is only called from a view which takes IPagedProgramList (provides IPagination<ProgramDTO> { get; }), and I have two ViewModels implementing that interface (a simple search and an advanced search). But if this project grows and we add new ViewModels that use that Interface I would have to update the Pager partial view, and that seems bad / doesn’t scale / etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:46:41+00:00Added an answer on June 6, 2026 at 1:46 am

    So a nod to Ek0nomik who got me thinking outside the box on this one.

    Step 1: Make sure all pages that are going to use the Pager controller are passing all parameters via GET not POST. Use RedirectToAction if you must accept post somewhere and just translate all the parameters into primitive types for the GET method.

    Step 2: Don’t worry about adding .Link() to the Pager. As long as everything’s coming in via GET, you’re fine. It will look at the URL for the page and adjust the page number parameter as it needs to when you’re going forward/back.

    Step 3 (optional but recommended): For consistency across your application, somewhere (probably your Global.ascx.cs file) you should define a list of the page sizes you will support. In my case I used Dictionary<int,string> so that I could pass -1 as the PageSize value but display All (and of course the data layer must know that -1 means disable paging).

    Step 4: Add something like this to your pager partial view:

    <ul class="pageSizeSelector">
            @foreach (KeyValuePair<int,string> kvp in MvcApplication.AVAIL_PAGE_SIZES)
            {
                <li><a href="#" onclick="changePageSize(@kvp.Key)">@kvp.Value</a></li>
            }
     </ul>
    

    Step 5: The javascript function changePageSize is so simple, I couldn’t believe I hadn’t thought of this first (note: no jQuery required… just in case you’re not already using it, you don’t need to just for this).

    function changePageSize(size) {
      var PSpattern = /PageSize=\d+/i;
      var url = window.location.href;
      url = url.replace(PSpattern, "PageSize=" + size);
      window.location.href = url;
    }
    

    Step 6 (optional, unless you’re an Internet Troll): Profit!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to
I have a view passing on information from a database: def serve_article(request, id): served_article
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.