In ASP, an alternative way to implement pagination with JScript scripts.
Source: Internet
Author: User
<% @LANGUAGE = "JAVASCRIPT" codepage= "936"%>
<!--#include file= "connect.asp"-->
<!--#include file= "news.asp"-->
<%
var dataset,sql,datalist;
var i=0;
var j=0;
Datalist=new News ();
Dataset=server.createobject ("Adodb.recordset");
Sql= "SELECT * from news where ngroup= ' group News ' ORDER by id DESC";
Dataset.open (sql,dataconn,1,1);
Is there any data
if ((dataset.eof) && (DATASET.BOF)
{
Response.Write ("<BR>");
Response.Write ("= = = = = No = = = no)";
Response.Write ("<BR><BR>");
Response.End ();
}
Total Records
Numrecords=dataset.recordcount;
Set maximum number of records per page
pagesize=3;
Total pages
Numpages=math.ceil (numrecords/pagesize);
Current page
I=request.querystring ("Currentpageid"). Count;
if (i==0)
{
currentpageid=1;
}
Else
{
Currentpageid=parseint (Request.QueryString ("Currentpageid"));
}
Class
Previouspageid=currentpageid-1;
nextpageid=currentpageid+1;
homepage=1;
Endpage=numpages;
Content List
Dataset.movefirst;
Dataset.move ((CurrentPageID-1) *pagesize,1);
while (! Dataset.eof && j<pagesize)
{
Response.Write ("<a href=show.asp?id=" +dataset ("id") + "target=" _blank ">" +dataset ("subject") + "</a>< Br> ");
j=j+1;
Dataset.movenext;
}
Set URL
if (Currentpageid = = homepage)
{
Response.Write ("<p class= ' Normal ' ><a href=list.asp?) Currentpageid= "+homepage+" > Home </a> ");
Response.Write ("prev ");
Response.Write ("<a href=list.asp?") Currentpageid= "+nextpageid+" > Next </a> ");
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service