ASP article pagination Class
<%
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,xunitna
Me,xshowstyle)
strURL = Clsmain.joinchar (strFileName)
Dim I,pagestr
If xtotalnum > 0 Then
If xpagecount >= 1 Then
Select Case Xshowstyle
Case "1" ' Pagination Style 1: List all
Page numbers with fewer page numbers to use
Pagestr = pagestr & "<div
Id= "" ShowPage "" > "
Pagestr = pagestr & "<a
class= "" Totalpage "" > All "&xPageName&":<b> "& Xtotalnum &" </b> "& Xunitname
& "</a>"
Pagestr = Pagestr &
" <a class=" "PageInfo" "> Page:<b>" & Xcurrentpage & "/" & Xpagecount &
"</b></a>"
For I=1 to Xpagecount
If i = Xcurrentpage
Then
Pagestr =
Pagestr & " [<a class= "" CurrentPage "" ><font color= ' Red ' > "& I &
"</FONT></A>]"
Else
Pagestr =
Pagestr & " [<a href= "" & strURL & "Page=" & I & "" "
class= "" GoToPage "" > "& I &" </A>] "
End If
Next
Pagestr = Pagestr &
"</div>" &vbcrlf
Case "2" ' Pagination Style 2: Display home 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 &
" <a class=" "PageInfo" "> Page:<b>" & Xcurrentpage & "/" & Xpagecount &
"</b></a>"
If xcurrentpage > 1 Then
Pagestr = Pagestr &
" <a href=" "" & strURL & "page=1" "title=" "Home"
class= "" FirstPage "" >|‹</a> "
Pagestr = Pagestr &
" <a href=" "" & strURL & "Page=" & XCurrentPage-1 & "" "Title=" "Last
Page "" class= "" PrevPage "" >«</a> "
Else
Pagestr = Pagestr &
" <a class=" "FirstPage" ">|‹</a>"
Pagestr = Pagestr &
" <a class=" "PrevPage" ">«</a>"
End If
If Xcurrentpage < Xpagecount
Then
Pagestr = Pagestr &
" <a href=" "" & strURL & "Page=" & Xcurrentpage + 1 & "" title= "" Next
Page "" class= "" NextPage "" >»</a> "
Pagestr = Pagestr &
" <a href=" "& strURL &" Page= "& Xpagecount &" "title=" "Last" "
class= "" LastPage "" >›|</a> "&vbcrlf
Else
Pagestr = Pagestr &
" <a class=" "NextPage" ">»</a>"
Pagestr = Pagestr &
" <a class=" "LastPage" ">›|</a>" &vbcrlf
End If
Pagestr = Pagestr & "
<input id= "page" "type=" "Text" "Value=" "& Xcurrentpage &" "
Maxlength= "4" "title=" "Set page" "Size= ' 4 ' onmouseover=" "Javascript:this.focus
() This.select () "" Onkeydown= "" javascript:if (Window.event.keyCode = = 13)
Window.location.href= ' "& strURL &" Page= ' +this.value "" > "&vbcrlf
Pagestr = Pagestr & "
<input type= "button" "value=" "Go" "onclick=" "javascript:if
(document.getElementById (' page ')) window.location.href= ' "& strURL &
"Page= ' +document.getelementbyid" (' Page '). Value "" > "&vbcrlf
Pagestr = Pagestr &
"</div>" &vbcrlf
Case "3" ' Pagination Style 3: Display home page
, Top 10, bottom 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 &
" <a class=" "PageInfo" "> Page:<b>" & Xcurrentpage & "/" & Xpagecount &
"</b></a>"
p = (xCurrentPage-1) 10
If xcurrentpage = 1 Then
Pagestr = Pagestr &
" <a class=" "FirstPage" ">|‹</a>"
Else
Pagestr = Pagestr &
" <a href=" "" & strURL & "page=1" "title=" "Home"
class= "" FirstPage "" >|‹</a> "
End If
If p * > 0 Then
Pagestr = Pagestr &
" <a href=" "" & strURL & "Page=" & xCurrentPage-10 & "" title= "" 10
Page "" class= "" PrevPage "" >«</a> "
End If
For i= (p * ten + 1) to (p *
10 + 10)
If i = Xcurrentpage
Then
Pagestr =
Pagestr & " [<font color= ' Red ' ><a class= "" CurrentPage "" > "& I &
"</A></FONT>]"
Else
Pagestr =
Pagestr & " <a href=" "& strURL &" Page= "& I &" "title=" "Go to" &
I & "page" "class=" "GoToPage" ">" & I & "</a>"
End If
If i = Xpagecount
Then Exit for
Next
If I < Xpagecount Then
Pagestr = pagestr & " <a href=" "& strURL &" Page= "& I &" "title=" "
Next 10 page "" Class= "" NextPage "" >»</a> "
If xcurrentpage = Xpagecount
Then
Pagestr = Pagestr &
" <a class=" "LastPage" ">›|</a>"
Else
Pagestr = Pagestr &
" <a href=" "& strURL &" Page= "& Xpagecount &" "title=" "Last" "
class= "" LastPage "" >›|</a> "
End If
Pagestr = Pagestr &
"</div>" &vbcrlf
Case "4" ' Pagination Style 4: Display home page
And last page number, middle display part of page number
Pagestr = pagestr & "<div
Id= "" ShowPage "" > "
Pagestr = pagestr & "<a
class= "" Totalpage "" > All "&xPageName&":<b> "& Xtotalnum &" </b> "& Xunitname
& "</a>"
Pagestr = Pagestr &
" <a class=" "PageInfo" "> Page:<b>" & Xcurrentpage & "/" & Xpagecount &
"</b></a>"
If xcurrentpage > 4 Then
Pagestr = pagestr & " [<a href= "" "& strURL &" Page=1 ""
class= "" FirstPage "" >1</a>] ... "
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 & " [<font color= ' Red ' ><a class= "" CurrentPage "" > "&
I & "</A></FONT>]"
Else
Pagestr = pagestr & " [<a href= "" & strURL & "Page=" & I & "" "
class= "" GoToPage "" > "& I &" </A>] "
End If
End If
Next
If Xcurrentpage < Xpagecount
-3 Then pagestr = pagestr & " ... <a href=" "" & strURL & "Page="
& Xpagecount & "" "Class=" "LastPage" ">" & Xpagecount & "</a>"
Pagestr = Pagestr &
"</div>" &vbcrlf
Case "5" ' Pagination Style 5: Display home 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 &
" <a class=" "PageInfo" "> Page:<b>" & Xcurrentpage & "/" & Xpagecount &
"</b></a>"
If xcurrentpage > 1 Then
Pagestr = Pagestr &
" <a href=" "" & strURL & "Maxperpage=" & Xmaxperpage & "&page=1"
Title= "" Home "" class= "" FirstPage "" > Home </a> "
Pagestr = Pagestr &
" <a href=" "& strURL &" Maxperpage= "& Xmaxperpage &" &page= "&
XCurrentPage-1 & "" title= "" Previous page "" Class= "" FirstPage "" > Prev </a> "
Else
Pagestr = Pagestr &
" <font color= ' #999999 ' ><a class=" "FirstPage" "> Home </a></font>"
Pagestr = Pagestr &
" <font color= ' #999999 ' ><a class=" "PrevPage" "> Prev </a></font>"
End If
If Xcurrentpage < Xpagecount
Then
Pagestr = Pagestr &
" <a href=" "& strURL &" Maxperpage= "& Xmaxperpage &" &page= "&
Xcurrentpage + 1 & "" "Title=" "Next" "class=" "NextPage" "> Next </a>"
Pagestr = Pagestr &
" <a href=" "& strURL &" Maxperpage= "& Xmaxperpage &" &page= "&
Xpagecount & "" "Title=" "Last" "class=" "LastPage" "> Last </a>" &vbcrlf
Else
Pagestr = Pagestr &
" <font color= ' #999999 ' ><a class=" "NextPage" "> Next </a></font>"
Pagestr = Pagestr &
" <font color= ' #999999 ' ><a class=" "LastPage" "> Last </a></font>"
End If
Pagestr = Pagestr &
" <input type=" "Text" "Size= ' 4 ' name=" "Maxperpage" "Maxlength=" "2" "
Value= "" "& Xmaxperpage &" "onkeypress=" "if (event.keycode==13)
Window.location.href= ' "& strURL &" Maxperpage= ' +this.value; " > "&
Xunitname & "/page" &vbcrlf
Pagestr = pagestr & "
Go to: <select id= "page" "class=" "Pageselect" "
Onchange= "" Window.location.href= ' "& 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 &
">" & I & "page </option>" &vbcrlf
Next
Pagestr = Pagestr & "
</select> "&vbcrlf
Pagestr = Pagestr &
"</div>" &vbcrlf
Case "6" ' Pagination Style 5: Display home 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 &
" <a class=" "PageInfo" "> Page:<b>" & Xcurrentpage & "/" & Xpagecount &
"</b></a>"
Pagestr = Pagestr &
" <a class=" "Totalpage" ">" &xMaxPerPage&xUnitName& "/Page </a>"
p = (xCurrentPage-1) 10
If xcurrentpage = 1 Then
Pagestr = Pagestr &
" <a class=" "FirstPage" ">|‹</a>"
Else
Pagestr = Pagestr &
" <a href=" "" & strURL & "page=1" "title=" "Home"
class= "" FirstPage "" >|‹</a> "
End If
If p * > 0 Then
Pagestr = Pagestr &
" <a href=" "" & strURL & "Page=" & xCurrentPage-10 & "" title= "" 10
Page "" class= "" PrevPage "" >«</a> "
End If
For i= (p * ten + 1) to (p *
10 + 10)
If i = Xcurrentpage
Then
Pagestr =
Pagestr & " [<font color= ' Red ' ><a class= "" CurrentPage "" > "& I &
"</A></FONT>]"
Else
Pagestr =
Pagestr & " [<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 & " <a href=" "& strURL &" Page= "& I &" "title=" "
Next 10 page "" Class= "" NextPage "" >»</a> "
If xcurrentpage = Xpagecount
Then
Pagestr = Pagestr &
" <a class=" "LastPage" ">›|</a>" &vbcrlf
Else
Pagestr = Pagestr &
" [<a href= "" & strURL & "Page=" & Xpagecount & "" title= "" Last ""
class= "" LastPage "" >&RSAQUO;|</A>] "&vbcrlf
End If
Pagestr = pagestr & "
Go: <input id= "" Page "size= ' 4 ' type=" "Text" "Value=" "" & Xcurrentpage &
"" "Maxlength=" "4" "title=" "onmouseover=" "Javascript:this.focus
() This.select () "" Onkeydown= "" javascript:if (Window.event.keyCode = = 13)
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
%>