?
Solved

ASP Paging with a difference

Posted on 2008-10-28
2
Medium Priority
?
254 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

770 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