ASP Paging Implementation Code

Source: Internet
Author: User
Tags servervariables

Provide a more complete ASP tutorial paging function, this page class can achieve the previous page, the next page, and other functions.

' For reference only, you may arbitrarily modify, propagate; If you have improved it, I hope you can give me a
' Copy, thank you.
'--------------------------------------------------------------------

Class Turnpage
Dim Spageno,spagesize,spagecount,srecordcount,sabsoluterecord

Private Sub Class_Initialize ()
Spageno=trim (Request.QueryString ("PageNo"))
If spageno<> "" Then
Spageno = CDbl (Spageno)
Else
Spageno = 1
End If
Sabsoluterecord = 1
End Sub

Public Sub Getrs (ByRef conn,byref rs,byval sql,byval pagesize)
Rs.Open sql,conn,1,1

Rs.pagesize = pagesize
Spagesize = Rs.pagesize
Spagecount = Rs.pagecount
Srecordcount = Rs.recordcount

If not rs.eof then Rs.absolutepage = Spageno
End Sub

Public Function EOF ()
If Sabsoluterecord<=spagesize Then
' Sabsoluterecord = Sabsoluterecord + 1
EOF = False
Else
EOF = True
End If
End Function

Public Sub MoveNext ()
Sabsoluterecord = Sabsoluterecord + 1
End Sub


Public Sub Getpagelist ()
If Spagecount<=1 then Exit Sub

Dim surl,stmp,squery_string,p,n,i,a,b

sURL = Request.ServerVariables ("url")
squery_string = Request.ServerVariables ("query_string")
STMP = Split (sURL, "/")
sURL = Stmp (UBound (STMP))
If squery_string <> "" Then Squery_string=replace (squery_string, "pageno=" & Spageno, "")
If squery_string = "" Then
sURL = sURL & "?"
Else
sURL = sURL & "?" & Squery_string & "&"
End If
sURL = replace (sURL, "&&", "&")

p = spageno-1
n = spageno+1
If p<1 then P = 1
If N>spagecount then n = spagecount

A = Spageno-5
b = spageno+5
If a<1 then a = 1
If B>spagecount then B = Spagecount

Response.Write ("<div class=" "Page_nav" ">")

If Spageno>1 then Response.Write ("<a href=" "" & sURL & "Pageno=1" "> Home </a> <a href=" "& sURL & "Pageno=" & P & "" > Prev page </a> "

For I=a to B
Response.Write ("<a href=" "" & sURL & "pageno=" & I & "" ")
If i = Spageno then Response.Write ("style=" "font-weight:bold; color: #ff0000;" ")
Response.Write (">" & I & "</a>")
Next
If Spageno < Spagecount then Response.Write ("<a href=" "" & sURL & "pageno=" & N & "" > Next page &LT;/A&G T <a href= "" "& sURL &" pageno= "& Spagecount &" "" > Last </a> "

Response.Write ("</div>")
End Sub

Public Sub Getpagehtmllist (BaseURL)
If Spagecount<=1 then Exit Sub

Dim p,n,i,a,b

p = spageno-1
n = spageno+1
If p<1 then P = 1
If N>spagecount then n = spagecount

A = Spageno-5
b = spageno+5
If a<1 then a = 1
If B>spagecount then B = Spagecount

Response.Write ("<div class=" "Page_nav" ">")

If Spageno>1 then Response.Write ("<a href=" "" & BaseURL & "_1.html" "> Home </a> <a href=" "" & Ba Seurl & "_" & P & ". html" "> Page </a>")

For I=a to B
Response.Write ("<a href=" "& BaseURL &" _ "& I &". html "" ")
If i = Spageno then Response.Write ("style=" "font-weight:bold; color: #ff0000;" ")
Response.Write (">" & I & "</a>")
Next
If Spageno < Spagecount then Response.Write ("<a href=" "& BaseURL &" _ "& N &". html "" > next page </a > <a href= "" "& BaseURL &" _ "& Spagecount &". html "> Last </a>")

Response.Write ("</div>")
End Sub
End Class

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.