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 8481709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:37:55+00:00 2026-06-10T19:37:55+00:00

I have implemented this pager based on the nerddinner tutorial . I had previously

  • 0

I have implemented this pager based on the nerddinner tutorial.

I had previously set this up to list all the pages in between the first and last links, however this is growing out of control now 🙂 In the below example I have the HTML / Code nuggets for the paging. I now have the page number list in between the First, and Last links reduced to just 10.

This does not change however. It will still list 1-10 regardless of the page I am on. I would like it to display links for the next 10 pages. Any help would be appreciated!

<ul id="paginator">
    <% if (Model.HasPreviousPage)
       { %>
    <li>
        <%= Html.RouteLink("First Page", new { namespaces = "Admin", controller = "Products", action = "ViewAll", page = 0 })%></li>
    <% } %>
    <% else %>
    <% { %>
    <li>First Page</li>
    <% } %>
    <% for (int i = 0; i < 10; i++) %>
    <% { %>
    <% if (i == Model.PageIndex) %>
    <% { %>
    <li>
        <%: i+1 %></li>
    <% } %>
    <% else %>
    <% { %>
    <li>
        <%= Html.RouteLink((i + 1).ToString(), new { namespaces = "Admin", controller = "Products", action = "ViewAll", page = i })%>
    </li>
    <% } %>
    <% } %>-->
    <% if (Model.HasNextPage)
       { %>
    <li>
        <%= Html.RouteLink("Last Page", new { namespaces = "Admin", controller = "Products", action = "ViewAll", page = Model.TotalPages - 1 })%></li>
    <% } %>
    <% else %>
    <% { %>
    <li>Last Page</li>
    <% } %>
</ul>
  • 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-10T19:37:56+00:00Added an answer on June 10, 2026 at 7:37 pm

    You can use your current page to decide where to place your 10 items, ideally I imagine you would want to display 5 pages either side of the current page (or ‘n’ pages either side of the current page). The algorithm for this is reasonably easy to implement…

    var startingPage = currentPage - 5;
    var endingPage = currentPage + 5;
    

    The only complication to add to this is that if the starting page is less than 1, or the ending page is greater than the final page, you’ll need to shim your 10 results.

    Lastly, you would need to handle the case where there aren’t 11 pages of results!

    var startingPage = currentPage - 5;
    if (startingPage < 1) {
        startingPage = 1;
    }
    
    var endingPage = currentPage + 11;
    if (endingPage > numberOfPages) {
        endingPage = numberOfPages;
    }
    

    You now have the start and end of your loop to create the page links, with the current page in the middle except at the start and end of paging.

    for (int i = startingPage; i < endingPage; i++)
    

    You could move the hard-coded values out of this code and shorten the expressions in your production code – I have done things in the way I think will make the concept easiest.

    I would also recommend moving this logic into a helper class that can create page links wherever you need them if you have more than one page that needs this logic.

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

Sidebar

Related Questions

In our application we have implemented role-based forms authentication. This has been handled using
So, I have implemented this method to add a footer to my table view:
I have a collection class MyCollection<T> . I have implemented T this[string name] ,
I have a singleton implemented like this: class Test123(object): _instance = None def __new__(cls,
I have implemented correctly bump's api, and added this code: - (void) configureBump {
Looking at this article: http://www.galloway.me.uk/tutorials/singleton-classes/ I have implemented a singleton, my question is the
I haven't yet implemented this, I'm still in the thinking stage, but I have
This is related to OpenId authentication. I have implemented the google and yahoo openId
This is regarding AES algorithm. Suppose i have implemented a AES algorithm and encrypt
I was wondering how other people implemented this scenario. I have an internal rails

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.