MobileToones Referral Contest Winners Google Introduced Gmail Printing Service
Mar 30

This is ASP based pagination script, similiar to Digg.com pagination. The credit goes to Jason Coleman who written this script in PHP and I simply converted this into ASP. I have attached screenshot this will help you to see how it looks like.

Demo Digg Style Pagination Script

Download Script

13 Responses to “ASP: Digg Style Pagination Script”

  1. Michael Says:

    What have you found to be the best way to convert php scripts to asp/asp.net?

  2. JOJY Says:

    you should have knowledge of asp/php syntax.. functions are almost similar or you may find easily by searching documentation.. I have good knowledge in both languages.. so it took just 25 mins to convert this script.

  3. Stupidcat Says:

    Can you provide an example of using this script? Thank you.

  4. JOJY Says:

    Its simple.. download the script, run the file pagination.asp .. and you will the demo!

  5. Tempa Says:

    Hi,

    There is a bug in the script. When you increase the adjacent value to more then 2 to let say 4 it disables the “Next” button when you reach the last page just before the first break “…”.

    Regards,

  6. Tempa Says:

    Near Line 115:
    [CODE]
    ‘close to beginning only hide later pages
    if page

  7. JOJY Says:

    Tampa, when you reach to last page it will obviously disable the next button.. there isn’t any bug..

  8. Lucas Soler Says:

    Hello !!
    Excelent Script, many thanks !!!!
    Only one bug, try this :

    Press “Next” Button, and then press the last page. The script go to page 1, and no the last. This problem is becouse the parametrers is ?foo=barpage=938 (and the correct syntax is ?foo=bar&page=938). The “&” betwen bar and page).

    Thanks again, and sorry for my bad, bad english

  9. Lucas Soler Says:

    Hello again, I found the error in line 147

    pagination = pagination & ““&lastpage&”

    The correct is

    pagination = pagination & ““&lastpage&”

  10. Alejandro Barrere Says:

    Hi,

    Good script but question… how do you attached this into records from your database? (access)

    I will appreciate your help.

    Regards,
    Alejandro.

  11. Meg Says:

    Hi thanks alot fro the script. It works great. but i want to know how can i link it to a recordset. and how if i place the function in a new page and call it as a include file. right now i manage to call it from include file and i can display teh records..let say the 15 records. but when i click next it doesnt move to the next 15 records. please help..i really appreciate it.

    sSQL1 = “SELECT * FROM country1 ”
    set RsCountry = conn.Execute(sSQL1)
    slimit=15
    stargetpage=”testpagination.asp?foo=bar”
    sadjacent=2
    ps = getPaginationString(page, sstring, slimit, sadjacent, stargetpage)

    If Not RsCountry.EOF Then

    Country ID
    CountryCode
    CountryName
    TelephoneCCode

    <tr bgcolor=”" align=”center”>

    this is in testpagination paeg and the function is in function page. right now the output of the code is a single record and stays the same on click of any page.

  12. Jovanky De Los Santos Says:

    Meg and others, JoyJ is rigth, if you don’t dominate ASP you may have a problem applying this script to it. But this is as simple as it gets. All you have to do is look at the following piece of code:
    ps = getPaginationString(page, 1500, 15, 2, “mytestpage3.asp?foo=bar”)

    See, the number 1500 reflects the full amount of records your recordset will return, 15 reflects how many you want to display per page. So all you need to do is store the amount of returnede records into a variable and replace the 1500 with it, then establish the amount of records you want to be displayed per page by replacing number 15 with whatever number of records you want to show on each page. The last thing you will need to do is modify your SQL query to return the total amount of records so you can store it on the variable, but also based on the ?foo=bar&page=PageNumber value, you can use this as a querystring to tell your query the range of records you want to read from, for instance, if you determine that you have a total of 100 recs and want to split them by ten each, then your query shoud return 1 - 10 when ?foo=bar&page=1, then 10 - 20 when ?foo=bar&page=2 and so on…

    Good luck

  13. Jovanky De Los Santos Says:

    Here is a piece of the code I implemented, I hope it helps

    Comm.CommandText = “Select Count(*) as Count from articles”
    Set RS = Comm.Execute
    Reqs = RS(”Count”)
    Page = Request(”Page”)
    If Page = “” then Page = 1
    comm.commandtext = “SELECT *”&_
    “FROM (SELECT ROW_NUMBER() OVER(ORDER BY Article_id) AS “&_
    “rownum, Article_ID, Title, Body, Create_date, “&_
    “meta_description FROM articles) AS Articles2 “&_
    “WHERE rownum >= “&Page&” AND rownum <= “&Cint(page)+ 5

Leave a Reply