Classic ASP Paging program code
<%
Class Cls_page
'**************************************************
' Function name: showpage
' Function: Show pagination
' Parameters: as follows
' strFileName: The following file, such as xxx.asp?page=
' Xtotalnum: Total
' Xpagecount: Total pages
' Xmaxperpage: Display quantity per page
' Xcurrentpage: Current page
' Xpagename: Current page name
' Xunitname: Classification unit name, such as "article, section, amplitude"
' Xshowstyle: Style to display page pagination
' Return value: Paging
'**************************************************
Public Function showpage (Strfilename,xtotalnum,xpagecount,xmaxperpage,xcurrentpage,xpagename,xunitname, Xshowstyle)
strURL = Clsmain.joinchar (strFileName)
Dim I,pagestr
If xtotalnum > 0 Then
If xpagecount >= 1 Then
Select Case Xshowstyle
Case "1" ' Pagination Style 1: Lists all page numbers, with fewer page numbers available
Pagestr = pagestr & "<div id=" "ShowPage" ">"
Pagestr = pagestr & "<a class=" "Totalpage" "> All" &xPageName& ":<b>" & Xtotalnum & "</b > "& xunitname &" </a> "
Pagestr = pagestr & "&nbsp;<a class=" "PageInfo" "> Page times:<b>" & Xcurrentpage & "/" & Xpagecoun T & "</b></a>"
For I=1 to Xpagecount
If i = Xcurrentpage Then
Pagestr = pagestr & "&nbsp; [<a class= "" CurrentPage "" ><font color= ' Red ' > "& I &" </FONT></A>] "
Else
Pagestr = pagestr & "&nbsp; [<a href= "" & strURL & "Page=" & I & "" "Class=" "GoToPage" ">" & I & "</A>]"
End If
Next
Pagestr = pagestr & "</div>" &vbcrlf
Case "2" ' Pagination Style 2: Display the first page, Prev, Next, last, all symbols and go to the page's input box
Pagestr = pagestr & "<div id=" "ShowPage" ">"
Pagestr = pagestr & "<a class=" "Totalpage" "> All" &xPageName& ":<b>" & Xtotalnum & "</b > "& xunitname &" </a> "
Pagestr = pagestr & "&nbsp;<a class=" "PageInfo" "> Page times:<b>" & Xcurrentpage & "/" & Xpagecoun T & "</b></a>"
If xcurrentpage > 1 Then
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" page=1 "" title= "" Home "" class= "" FirstPage "" >|& Lsaquo;</a> "
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" Page= "& XCurrentPage-1 &" "title=" "Previous page" "Class=" "PrevPage" ">&laquo;</a>"
Else
Pagestr = pagestr & "&nbsp;<a class=" "FirstPage" ">|&lsaquo;</a>"
Pagestr = pagestr & "&nbsp;<a class=" "PrevPage" ">&laquo;</a>"
End If
If Xcurrentpage < Xpagecount Then
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" Page= "& Xcurrentpage + 1 &" "title=" "Next page" "Class=" "NextPage" ">&raquo;</a>"
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" Page= "& Xpagecount &" "title=" "Last" "Class = "" "LastPage" ">&rsaquo;|</a>" &vbcrlf
Else
Pagestr = pagestr & "&nbsp;<a class=" "NextPage" ">&raquo;</a>"
Pagestr = pagestr & "&nbsp;<a class=" "LastPage" ">&rsaquo;|</a>" &vbcrlf
End If
Pagestr = pagestr & "<input id=" "Page" "type=" "Text" "Value=" "& Xcurrentpage &" "Maxlength=" "4" "titl "E=" "size= ' 4 ' onmouseover=" "Javascript:this.focus (); This.select ()" "Onkeydown=" "Javascript:if ( Window.event.keyCode = Window.location.href= ' "& strURL &" Page= ' +this.value "" > "&vbcrlf
Pagestr = pagestr & "<input type=" "button" "value=" "Go" "onclick=" "Javascript:if" (' Page ') window.location.href= ' & strURL & ' page= ' +document.getelementbyid (' page '). Value "" > "&vbcrlf
Pagestr = pagestr & "</div>" &vbcrlf
Case "3" ' Pagination Style 3: Display first page, Top 10, next 10, Last and middle section of page number
Pagestr = pagestr & "<div id=" "ShowPage" ">"
Pagestr = pagestr & "<a class=" "Totalpage" "> All" &xPageName& ":<b>" & Xtotalnum & "</b > "& xunitname &" </a> "
Pagestr = pagestr & "&nbsp;<a class=" "PageInfo" "> Page times:<b>" & Xcurrentpage & "/" & Xpagecoun T & "</b></a>"
p = (xCurrentPage-1) 10
If xcurrentpage = 1 Then
Pagestr = pagestr & "&nbsp;<a class=" "FirstPage" ">|&lsaquo;</a>"
Else
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" page=1 "" title= "" Home "" class= "" FirstPage "" >|& Lsaquo;</a> "
End If
If p * > 0 Then
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" Page= "& xCurrentPage-10 &" "title=" "10 pages "Class=" "PrevPage" ">&laquo;</a>"
End If
For i= (p * ten + 1) to (p * 10 + 10)
If i = Xcurrentpage Then
Pagestr = pagestr & "&nbsp; [<font color= ' Red ' ><a class= "" CurrentPage "" > "& I &" </A></FONT>] "
Else
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" Page= "& I &" "title=" "Goto" & I & "Page" "class=" "GoToPage" ">" & I & "</a>"
End If
If i = Xpagecount Then Exit for
Next
If i < xpagecount Then pagestr = pagestr & "&nbsp;<a href=" "" & strURL & "Page=" & I & "" t Itle= "" Next 10 Pages "" Class= "" NextPage "" >&raquo;</a> "
If xcurrentpage = Xpagecount Then
Pagestr = pagestr & "&nbsp;<a class=" "LastPage" ">&rsaquo;|</a>"
Else
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" Page= "& Xpagecount &" "title=" "Last" "Class = "" LastPage "" >&rsaquo;|</a> "
End If
Pagestr = pagestr & "</div>" &vbcrlf
Case "4" ' Pagination Style 4: Display first and last page number, middle display part Page number
Pagestr = pagestr & "<div id=" "ShowPage" ">"
Pagestr = pagestr & "<a class=" "Totalpage" "> All" &xPageName& ":<b>" & Xtotalnum & "</b > "& xunitname &" </a> "
Pagestr = pagestr & "&nbsp;<a class=" "PageInfo" "> Page times:<b>" & Xcurrentpage & "/" & Xpagecoun T & "</b></a>"
If xcurrentpage > 4 Then pagestr = pagestr & "&nbsp; [<a href= "" & strURL & "page=1" "class=" "FirstPage" ">1</a>]&nbsp;...&nbsp;"
If Xcurrentpage < PageCount-3 Then PageTo = xcurrentpage + 3 Else pageto = Xpagecount
For i=xcurrentpage-3 to PageTo
If I >= 1 Then
If i = Xcurrentpage Then
Pagestr = pagestr & "&nbsp; [<font color= ' Red ' ><a class= "" CurrentPage "" > "& I &" </A></FONT>] "
Else
Pagestr = pagestr & "&nbsp; [<a href= "" & strURL & "Page=" & I & "" "Class=" "GoToPage" ">" & I & "</A>]"
End If
End If
Next
If Xcurrentpage < xPageCount-3 Then pagestr = pagestr & "&nbsp;...&nbsp;<a href=" "" & strURL & "Page=" & Xpagecount & "" "Class=" "LastPage" ">" & Xpagecount & "</a>"
Pagestr = pagestr & "</div>" &vbcrlf
Case "5" ' Pagination Style 5: Display the first page, Prev, Next, last, all Chinese characters and go to the selection list of the page
Pagestr = pagestr & "<div id=" "ShowPage" ">"
Pagestr = pagestr & "<a class=" "Totalpage" "> All" &xPageName& ":<b>" & Xtotalnum & "</b > "& xunitname &" </a> "
Pagestr = pagestr & "&nbsp;<a class=" "PageInfo" "> Page times:<b>" & Xcurrentpage & "/" & Xpagecoun T & "</b></a>"
If xcurrentpage > 1 Then
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" Maxperpage= "& Xmaxperpage &" &page=1 "" Title= "" Home "" class= "" FirstPage "" > Home </a> "
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" Maxperpage= "& Xmaxperpage &" &page= "&A mp XCurrentPage-1 & "" title= "" Previous page "" Class= "" FirstPage "" > Prev </a> "
Else
Pagestr = pagestr & "&nbsp;<font color= ' #999999 ' ><a class=" "FirstPage" "> Home </a></font > "
Pagestr = pagestr & "&nbsp;<font color= ' #999999 ' ><a class=" "PrevPage" "> previous page </a></font > "
End If
If Xcurrentpage < Xpagecount Then
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" Maxperpage= "& Xmaxperpage &" &page= "&A mp Xcurrentpage + 1 & "" "Title=" "Next" "class=" "NextPage" "> Next </a>"
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" Maxperpage= "& Xmaxperpage &" &page= "&A mp Xpagecount & "" "Title=" "Last" "class=" "LastPage" "> Last </a>" &vbcrlf
Else
Pagestr = pagestr & "&nbsp;<font color= ' #999999 ' ><a class=" "NextPage" "> next page </a></font > "
Pagestr = pagestr & "&nbsp;<font color= ' #999999 ' ><a class=" "LastPage" "> Last page </a></font> "
End If
Pagestr = pagestr & "&nbsp;<input type=" "Text" "Size= ' 4 ' name=" "Maxperpage" "Maxlength=" "2" "Value=" "" & X Maxperpage & "" onkeypress= "" if (event.keycode==13) window.location.href= ' "& strURL &" maxperpage= "+ This.value; "" >&nbsp; "& Xunitname &"/page "&vbcrlf
Pagestr = pagestr & &nbsp; goto: <select id= "page" "class=" "Pageselect" "onchange=" "Window.location.href=" "& Amp strURL & "Maxperpage=" & Xmaxperpage & "&page= ' +this.options[this.selectedindex].value" ">" & vbCrLf
For I=1 to Xpagecount
Pagestr = pagestr & "<option value=" "& I &" "" "
If i = xcurrentpage Then pagestr = pagestr & "Selected"
Pagestr = Pagestr & "> First" & I & "page </option>" &vbcrlf
Next
Pagestr = pagestr & "</select>" &vbcrlf
Pagestr = pagestr & "</div>" &vbcrlf
Case "6" ' Pagination Style 5: Display first page, Prev, Next, last, digital page and turn text box
Pagestr = pagestr & "<div id=" "ShowPage" ">"
Pagestr = pagestr & "<a class=" "Totalpage" "> All" &xPageName& ":<b>" & Xtotalnum & "</b > "& xunitname &" </a> "
Pagestr = pagestr & "&nbsp;<a class=" "PageInfo" "> Page times:<b>" & Xcurrentpage & "/" & Xpagecoun T & "</b></a>"
Pagestr = pagestr & "&nbsp;<a class=" "Totalpage" ">" &xMaxPerPage&xUnitName& "/Page </a>"
p = (xCurrentPage-1) 10
If xcurrentpage = 1 Then
Pagestr = pagestr & "&nbsp;<a class=" "FirstPage" ">|&lsaquo;</a>"
Else
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" page=1 "" title= "" Home "" class= "" FirstPage "" >|& Lsaquo;</a> "
End If
If p * > 0 Then
Pagestr = pagestr & "&nbsp;<a href=" "& strURL &" Page= "& xCurrentPage-10 &" "title=" "10 pages "Class=" "PrevPage" ">&laquo;</a>"
End If
For i= (p * ten + 1) to (p * 10 + 10)
If i = Xcurrentpage Then
Pagestr = pagestr & "&nbsp; [<font color= ' Red ' ><a class= "" CurrentPage "" > "& I &" </A></FONT>] "
Else
Pagestr = pagestr & "&nbsp; [<a href= "" & strURL & "Page=" & I & "" "Title=" "Goto" & I & "page" "class=" "GoToPage" ">" & I & "</A>]"
End If
If i = Xpagecount Then Exit for
Next
If i < xpagecount Then pagestr = pagestr & "&nbsp;<a href=" "" & strURL & "Page=" & I & "" t Itle= "" Next 10 Pages "" Class= "" NextPage "" >&raquo;</a> "
If xcurrentpage = Xpagecount Then
Pagestr = pagestr & "&nbsp;<a class=" "LastPage" ">&rsaquo;|</a>" &vbcrlf
Else
Pagestr = pagestr & "&nbsp; [<a href= "" & strURL & "Page=" & Xpagecount & "" "Title=" "Last" "class=" "LastPage" ">&rsaquo;|< ;/a>] "&vbcrlf
End If
Pagestr = pagestr & &nbsp; goto: <input id= "page" size= ' 4 ' type= ' "text" "Value=" "" & Xcurrentpage & "" " Maxlength= "4" "title=" "page" "Onmouseover=" "Javascript:this.focus () This.select ()" "Onkeydown=" "Javascript:if ( Window.event.keyCode = Window.location.href= ' "& strURL &" Page= ' +this.value "" > page "&vbcrlf
Pagestr = pagestr & "</div>" &vbcrlf
End Select
End If
Else
Pagestr = "" &vbcrlf
End If
ShowPage = Pagestr
End Function
End Class
%>