ASP common pagination Style function code _ Application Tips
Source: Internet
Author: User
<%
'******************************
' Function: MultiPage (NUMBERS,PERPAGE,CURPAGE,URL_ADD)
' Parameters: Numbers, total number of records, Perpage, number of records per page, Curpage, current page, Url_add, other parameters of current page such as?action=list&
' Author: Arisisi
' Date: 2007/7/15
' Description: ASP common paging style function
' Example: MultiPage (100,10,2, "?action=list&")
'******************************
Function MultiPage (Numbers,perpage,curpage,url_add)
Curpage=int (Curpage)
Dim URL
Url=request.servervariables ("Script_name") &url_add
Multipage= ""
Dim Page,offset,pagei
If Int (Numbers) >int (perpage) Then
page=10
offset=2
Dim Pages,frompage,topage
If Numbers Mod Cint (perpage) =0 Then
Pages=int (Numbers/perpage)
Else
Pages=int (numbers/perpage) +1
End If
Frompage=curpage-offset
Topage=curpage+page-offset-1
If page>pages Then
Frompage=1
Topage=pages
Else
If frompage<1 Then
Topage=curpage+1-frompage
Frompage=1
If (Topage-frompage) <page and (topage-frompage) <pages Then topage=page
ElseIF topage>pages Then
FromPage =curpage-pages +topage
Topage=pages
If (Topage-frompage) <page and (topage-frompage) <pages Then frompage=pages-page+1
End If
End If
multipage= "<a href= '" &Url& "page=1 ' ><<</a>"
For Pagei=frompage to ToPage
If Pagei<>curpage Then
multipage=multipage& "<a href= '" &Url& "page=" &PageI& ">[" &PageI& "]</a>"
Else
multipage=multipage& "<b>[" &PageI& "]</b>"
End If
Next
If Int (Pages) >int (Page) Then
multipage=multipage& "... <a href= '" &Url& "page=" &Pages& "' > [" &pages& "] >> </a> "
Else
multipage=multipage& "<a href= '" &Url& "page=" &Pages& ">>></a>"
End If
End If
End Function%>
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