Solved

ASP Paging with a difference

Posted on 2008-10-28
2
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

729 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