Classic ASP Paging program code

Source: Internet
Author: User
Tags goto prev classic asp

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 &gt; 0 Then


If xpagecount &gt;= 1 Then


Select Case Xshowstyle


Case "1" ' Pagination Style 1: Lists all page numbers, with fewer page numbers available


Pagestr = pagestr &amp; "&lt;div id=" "ShowPage" "&gt;"


Pagestr = pagestr &amp; "&lt;a class=" "Totalpage" "&gt; All" &amp;xPageName&amp; ":&lt;b&gt;" &amp; Xtotalnum &amp; "&lt;/b &gt; "&amp; xunitname &amp;" &lt;/a&gt; "


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "PageInfo" "&gt; Page times:&lt;b&gt;" &amp; Xcurrentpage &amp; "/" &amp; Xpagecoun T &amp; "&lt;/b&gt;&lt;/a&gt;"


For I=1 to Xpagecount


If i = Xcurrentpage Then


Pagestr = pagestr &amp; "&amp;nbsp; [&lt;a class= "" CurrentPage "" &gt;&lt;font color= ' Red ' &gt; "&amp; I &amp;" &LT;/FONT&GT;&LT;/A&GT;] "


Else


Pagestr = pagestr &amp; "&amp;nbsp; [&lt;a href= "" &amp; strURL &amp; "Page=" &amp; I &amp; "" "Class=" "GoToPage" "&gt;" &amp; I &amp; "&LT;/A&GT;]"


End If


Next


Pagestr = pagestr &amp; "&lt;/div&gt;" &amp;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 &amp; "&lt;div id=" "ShowPage" "&gt;"


Pagestr = pagestr &amp; "&lt;a class=" "Totalpage" "&gt; All" &amp;xPageName&amp; ":&lt;b&gt;" &amp; Xtotalnum &amp; "&lt;/b &gt; "&amp; xunitname &amp;" &lt;/a&gt; "


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "PageInfo" "&gt; Page times:&lt;b&gt;" &amp; Xcurrentpage &amp; "/" &amp; Xpagecoun T &amp; "&lt;/b&gt;&lt;/a&gt;"


If xcurrentpage &gt; 1 Then


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" page=1 "" title= "" Home "" class= "" FirstPage "" &gt;|&amp; Lsaquo;&lt;/a&gt; "


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" Page= "&amp; XCurrentPage-1 &amp;" "title=" "Previous page" "Class=" "PrevPage" "&gt;&amp;laquo;&lt;/a&gt;"


Else


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "FirstPage" "&gt;|&amp;lsaquo;&lt;/a&gt;"


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "PrevPage" "&gt;&amp;laquo;&lt;/a&gt;"


End If


If Xcurrentpage &lt; Xpagecount Then


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" Page= "&amp; Xcurrentpage + 1 &amp;" "title=" "Next page" "Class=" "NextPage" "&gt;&amp;raquo;&lt;/a&gt;"


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" Page= "&amp; Xpagecount &amp;" "title=" "Last" "Class = "" "LastPage" "&gt;&amp;rsaquo;|&lt;/a&gt;" &amp;vbcrlf


Else


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "NextPage" "&gt;&amp;raquo;&lt;/a&gt;"


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "LastPage" "&gt;&amp;rsaquo;|&lt;/a&gt;" &amp;vbcrlf


End If


Pagestr = pagestr &amp; "&lt;input id=" "Page" "type=" "Text" "Value=" "&amp; Xcurrentpage &amp;" "Maxlength=" "4" "titl "E=" "size= ' 4 ' onmouseover=" "Javascript:this.focus (); This.select ()" "Onkeydown=" "Javascript:if ( Window.event.keyCode = Window.location.href= ' "&amp; strURL &amp;" Page= ' +this.value "" &gt; "&amp;vbcrlf


Pagestr = pagestr &amp; "&lt;input type=" "button" "value=" "Go" "onclick=" "Javascript:if" (' Page ') window.location.href= ' &amp; strURL &amp; ' page= ' +document.getelementbyid (' page '). Value "" &gt; "&amp;vbcrlf


Pagestr = pagestr &amp; "&lt;/div&gt;" &amp;vbcrlf


Case "3" ' Pagination Style 3: Display first page, Top 10, next 10, Last and middle section of page number


Pagestr = pagestr &amp; "&lt;div id=" "ShowPage" "&gt;"


Pagestr = pagestr &amp; "&lt;a class=" "Totalpage" "&gt; All" &amp;xPageName&amp; ":&lt;b&gt;" &amp; Xtotalnum &amp; "&lt;/b &gt; "&amp; xunitname &amp;" &lt;/a&gt; "


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "PageInfo" "&gt; Page times:&lt;b&gt;" &amp; Xcurrentpage &amp; "/" &amp; Xpagecoun T &amp; "&lt;/b&gt;&lt;/a&gt;"


p = (xCurrentPage-1) 10


If xcurrentpage = 1 Then


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "FirstPage" "&gt;|&amp;lsaquo;&lt;/a&gt;"


Else


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" page=1 "" title= "" Home "" class= "" FirstPage "" &gt;|&amp; Lsaquo;&lt;/a&gt; "


End If


If p * &gt; 0 Then


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" Page= "&amp; xCurrentPage-10 &amp;" "title=" "10 pages "Class=" "PrevPage" "&gt;&amp;laquo;&lt;/a&gt;"


End If


For i= (p * ten + 1) to (p * 10 + 10)


If i = Xcurrentpage Then


Pagestr = pagestr &amp; "&amp;nbsp; [&lt;font color= ' Red ' &gt;&lt;a class= "" CurrentPage "" &gt; "&amp; I &amp;" &LT;/A&GT;&LT;/FONT&GT;] "


Else


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" Page= "&amp; I &amp;" "title=" "Goto" &amp; I &amp; "Page" "class=" "GoToPage" "&gt;" &amp; I &amp; "&lt;/a&gt;"


End If


If i = Xpagecount Then Exit for


Next


If i &lt; xpagecount Then pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "" &amp; strURL &amp; "Page=" &amp; I &amp; "" t Itle= "" Next 10 Pages "" Class= "" NextPage "" &gt;&amp;raquo;&lt;/a&gt; "


If xcurrentpage = Xpagecount Then


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "LastPage" "&gt;&amp;rsaquo;|&lt;/a&gt;"


Else


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" Page= "&amp; Xpagecount &amp;" "title=" "Last" "Class = "" LastPage "" &gt;&amp;rsaquo;|&lt;/a&gt; "


End If


Pagestr = pagestr &amp; "&lt;/div&gt;" &amp;vbcrlf


Case "4" ' Pagination Style 4: Display first and last page number, middle display part Page number


Pagestr = pagestr &amp; "&lt;div id=" "ShowPage" "&gt;"


Pagestr = pagestr &amp; "&lt;a class=" "Totalpage" "&gt; All" &amp;xPageName&amp; ":&lt;b&gt;" &amp; Xtotalnum &amp; "&lt;/b &gt; "&amp; xunitname &amp;" &lt;/a&gt; "


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "PageInfo" "&gt; Page times:&lt;b&gt;" &amp; Xcurrentpage &amp; "/" &amp; Xpagecoun T &amp; "&lt;/b&gt;&lt;/a&gt;"


If xcurrentpage &gt; 4 Then pagestr = pagestr &amp; "&amp;nbsp; [&lt;a href= "" &amp; strURL &amp; "page=1" "class=" "FirstPage" "&gt;1&lt;/a&gt;]&amp;nbsp;...&amp;nbsp;"


If Xcurrentpage &lt; PageCount-3 Then PageTo = xcurrentpage + 3 Else pageto = Xpagecount


For i=xcurrentpage-3 to PageTo


If I &gt;= 1 Then


If i = Xcurrentpage Then


Pagestr = pagestr &amp; "&amp;nbsp; [&lt;font color= ' Red ' &gt;&lt;a class= "" CurrentPage "" &gt; "&amp; I &amp;" &LT;/A&GT;&LT;/FONT&GT;] "


Else


Pagestr = pagestr &amp; "&amp;nbsp; [&lt;a href= "" &amp; strURL &amp; "Page=" &amp; I &amp; "" "Class=" "GoToPage" "&gt;" &amp; I &amp; "&LT;/A&GT;]"


End If


End If


Next


If Xcurrentpage &lt; xPageCount-3 Then pagestr = pagestr &amp; "&amp;nbsp;...&amp;nbsp;&lt;a href=" "" &amp; strURL &amp; "Page=" &amp; Xpagecount &amp; "" "Class=" "LastPage" "&gt;" &amp; Xpagecount &amp; "&lt;/a&gt;"


Pagestr = pagestr &amp; "&lt;/div&gt;" &amp;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 &amp; "&lt;div id=" "ShowPage" "&gt;"


Pagestr = pagestr &amp; "&lt;a class=" "Totalpage" "&gt; All" &amp;xPageName&amp; ":&lt;b&gt;" &amp; Xtotalnum &amp; "&lt;/b &gt; "&amp; xunitname &amp;" &lt;/a&gt; "


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "PageInfo" "&gt; Page times:&lt;b&gt;" &amp; Xcurrentpage &amp; "/" &amp; Xpagecoun T &amp; "&lt;/b&gt;&lt;/a&gt;"


If xcurrentpage &gt; 1 Then


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" Maxperpage= "&amp; Xmaxperpage &amp;" &amp;page=1 "" Title= "" Home "" class= "" FirstPage "" &gt; Home &lt;/a&gt; "


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" Maxperpage= "&amp; Xmaxperpage &amp;" &amp;page= "&A mp XCurrentPage-1 &amp; "" title= "" Previous page "" Class= "" FirstPage "" &gt; Prev &lt;/a&gt; "


Else


Pagestr = pagestr &amp; "&amp;nbsp;&lt;font color= ' #999999 ' &gt;&lt;a class=" "FirstPage" "&gt; Home &lt;/a&gt;&lt;/font &gt; "


Pagestr = pagestr &amp; "&amp;nbsp;&lt;font color= ' #999999 ' &gt;&lt;a class=" "PrevPage" "&gt; previous page &lt;/a&gt;&lt;/font &gt; "


End If


If Xcurrentpage &lt; Xpagecount Then


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" Maxperpage= "&amp; Xmaxperpage &amp;" &amp;page= "&A mp Xcurrentpage + 1 &amp; "" "Title=" "Next" "class=" "NextPage" "&gt; Next &lt;/a&gt;"


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" Maxperpage= "&amp; Xmaxperpage &amp;" &amp;page= "&A mp Xpagecount &amp; "" "Title=" "Last" "class=" "LastPage" "&gt; Last &lt;/a&gt;" &amp;vbcrlf


Else


Pagestr = pagestr &amp; "&amp;nbsp;&lt;font color= ' #999999 ' &gt;&lt;a class=" "NextPage" "&gt; next page &lt;/a&gt;&lt;/font &gt; "


Pagestr = pagestr &amp; "&amp;nbsp;&lt;font color= ' #999999 ' &gt;&lt;a class=" "LastPage" "&gt; Last page &lt;/a&gt;&lt;/font&gt; "


End If


Pagestr = pagestr &amp; "&amp;nbsp;&lt;input type=" "Text" "Size= ' 4 ' name=" "Maxperpage" "Maxlength=" "2" "Value=" "" &amp; X Maxperpage &amp; "" onkeypress= "" if (event.keycode==13) window.location.href= ' "&amp; strURL &amp;" maxperpage= "+ This.value; "" &gt;&amp;nbsp; "&amp; Xunitname &amp;"/page "&amp;vbcrlf


Pagestr = pagestr &amp; &amp;nbsp; goto: &lt;select id= "page" "class=" "Pageselect" "onchange=" "Window.location.href=" "& Amp strURL &amp; "Maxperpage=" &amp; Xmaxperpage &amp; "&amp;page= ' +this.options[this.selectedindex].value" "&gt;" &amp; vbCrLf


For I=1 to Xpagecount


Pagestr = pagestr &amp; "&lt;option value=" "&amp; I &amp;" "" "


If i = xcurrentpage Then pagestr = pagestr &amp; "Selected"


Pagestr = Pagestr &amp; "&gt; First" &amp; I &amp; "page &lt;/option&gt;" &amp;vbcrlf


Next


Pagestr = pagestr &amp; "&lt;/select&gt;" &amp;vbcrlf


Pagestr = pagestr &amp; "&lt;/div&gt;" &amp;vbcrlf


Case "6" ' Pagination Style 5: Display first page, Prev, Next, last, digital page and turn text box


Pagestr = pagestr &amp; "&lt;div id=" "ShowPage" "&gt;"


Pagestr = pagestr &amp; "&lt;a class=" "Totalpage" "&gt; All" &amp;xPageName&amp; ":&lt;b&gt;" &amp; Xtotalnum &amp; "&lt;/b &gt; "&amp; xunitname &amp;" &lt;/a&gt; "


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "PageInfo" "&gt; Page times:&lt;b&gt;" &amp; Xcurrentpage &amp; "/" &amp; Xpagecoun T &amp; "&lt;/b&gt;&lt;/a&gt;"


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "Totalpage" "&gt;" &amp;xMaxPerPage&amp;xUnitName&amp; "/Page &lt;/a&gt;"


p = (xCurrentPage-1) 10


If xcurrentpage = 1 Then


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "FirstPage" "&gt;|&amp;lsaquo;&lt;/a&gt;"


Else


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" page=1 "" title= "" Home "" class= "" FirstPage "" &gt;|&amp; Lsaquo;&lt;/a&gt; "


End If


If p * &gt; 0 Then


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "&amp; strURL &amp;" Page= "&amp; xCurrentPage-10 &amp;" "title=" "10 pages "Class=" "PrevPage" "&gt;&amp;laquo;&lt;/a&gt;"


End If


For i= (p * ten + 1) to (p * 10 + 10)


If i = Xcurrentpage Then


Pagestr = pagestr &amp; "&amp;nbsp; [&lt;font color= ' Red ' &gt;&lt;a class= "" CurrentPage "" &gt; "&amp; I &amp;" &LT;/A&GT;&LT;/FONT&GT;] "


Else


Pagestr = pagestr &amp; "&amp;nbsp; [&lt;a href= "" &amp; strURL &amp; "Page=" &amp; I &amp; "" "Title=" "Goto" &amp; I &amp; "page" "class=" "GoToPage" "&gt;" &amp; I &amp; "&LT;/A&GT;]"


End If


If i = Xpagecount Then Exit for


Next


If i &lt; xpagecount Then pagestr = pagestr &amp; "&amp;nbsp;&lt;a href=" "" &amp; strURL &amp; "Page=" &amp; I &amp; "" t Itle= "" Next 10 Pages "" Class= "" NextPage "" &gt;&amp;raquo;&lt;/a&gt; "


If xcurrentpage = Xpagecount Then


Pagestr = pagestr &amp; "&amp;nbsp;&lt;a class=" "LastPage" "&gt;&amp;rsaquo;|&lt;/a&gt;" &amp;vbcrlf


Else


Pagestr = pagestr &amp; "&amp;nbsp; [&lt;a href= "" &amp; strURL &amp; "Page=" &amp; Xpagecount &amp; "" "Title=" "Last" "class=" "LastPage" "&gt;&amp;rsaquo;|&lt ;/a&gt;] "&amp;vbcrlf


End If


Pagestr = pagestr &amp; &amp;nbsp; goto: &lt;input id= "page" size= ' 4 ' type= ' "text" "Value=" "" &amp; Xcurrentpage &amp; "" " Maxlength= "4" "title=" "page" "Onmouseover=" "Javascript:this.focus () This.select ()" "Onkeydown=" "Javascript:if ( Window.event.keyCode = Window.location.href= ' "&amp; strURL &amp;" Page= ' +this.value "" &gt; page "&amp;vbcrlf

Pagestr = pagestr & "</div>" &vbcrlf

End Select
End If
Else
Pagestr = "" &vbcrlf
End If
ShowPage = Pagestr
End Function


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.