Solved

ASP Paging with a difference

Posted on 2008-10-28
2
232 Views
Last Modified: 2012-05-05
Hi guys,

I have a product list page that shows x pages of 6 products per page.  So if there is 60 products the paging will look like:

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10

This works fine.  However I don't want the links to get that 'wide'.  I want to only show up to 5 pages at once, i.e, if I was in the middle of the list, it would look like:

4 | 5 | 6 | 7 | 8

An example of this is the Tiffany's website: http://tinyurl.com/679jc8

Any ideas how to go about this in classic ASP?

Thanks a lot
0
Comment
Question by:chuck_norris666
2 Comments
 
LVL 8

Accepted Solution

by:
saoirse1916 earned 500 total points
ID: 22824677
I have a function that I use to create the paging system and it seems like you've got the same thing so I won't bother you with that.  Specifically, what I did to limit the number of linked pages, I did this:

If varNoPages > strMaxPageWidth Then
      Dim varPageHalfwayPoint
      varPageHalfwayPoint = Fix(strMaxPageWidth / 2)
      If strMaxPageWidth Mod 2 > 0 Then
            varPageHalfwayPoint = varPageHalfwayPoint + 1
      End If
      If strCurrentPage < varPageHalfwayPoint Then
            varPageStart = 1
            varPageEnd = strMaxPageWidth
      Else
            If strCurrentPage > (varNoPages - (Fix(strMaxPageWidth / 2))) Then
                  varPageStart = varNoPages - strMaxPageWidth
            Else
                  varPageStart = strCurrentPage - (Fix(strMaxPageWidth / 2))
            End If
            If strCurrentPage > varNoPages - (Fix(strMaxPageWidth / 2)) Then
                  varPageEnd = varNoPages
            Else
                  varPageEnd = strCurrentPage + (Fix(strMaxPageWidth / 2))
            End If
      End If
Else
      varPageStart = 1
      varPageEnd = varNoPages
End If

One of the values passed during my function is strMaxPageWidth which specifies the maximum number of linked page items that should be displayed.  If the total number of pages (varNoPages) is greater than strMaxPageWidth,  the function finds the halfway point and then identifies the proper number of items to be displayed on each side of that point.
0
 

Author Closing Comment

by:chuck_norris666
ID: 31510800
Mate, that worked brilliantly.  Thanks a lot!
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question