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.
April 9th, 2007 at 2:36 pm
What have you found to be the best way to convert php scripts to asp/asp.net?
April 9th, 2007 at 3:02 pm
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.
May 10th, 2007 at 5:56 pm
Can you provide an example of using this script? Thank you.
May 10th, 2007 at 10:59 pm
Its simple.. download the script, run the file pagination.asp .. and you will the demo!
May 26th, 2007 at 1:09 am
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,
May 26th, 2007 at 1:22 am
Near Line 115:
[CODE]
‘close to beginning only hide later pages
if page
May 26th, 2007 at 3:26 am
Tampa, when you reach to last page it will obviously disable the next button.. there isn’t any bug..
July 12th, 2007 at 5:24 am
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
July 12th, 2007 at 5:28 am
Hello again, I found the error in line 147
pagination = pagination & ““&lastpage&””
The correct is
pagination = pagination & ““&lastpage&”“
October 27th, 2007 at 8:49 pm
Hi,
Good script but question… how do you attached this into records from your database? (access)
I will appreciate your help.
Regards,
Alejandro.
November 29th, 2007 at 2:09 am
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.
December 28th, 2007 at 2:14 pm
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
December 28th, 2007 at 3:03 pm
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