Solved

ASP Paging with a difference

Posted on 2008-10-28
2
204 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
Comment Utility
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
Comment Utility
Mate, that worked brilliantly.  Thanks a lot!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now