Solved

ASP Paging with a difference

Posted on 2008-10-28
2
223 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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/…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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…

809 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