Automatic pagination code for ASP long articles

Source: Internet
Author: User

<%

Sub AutoPage ()

Dim Maxpagelen,page,content,pagenumber,articleid

Dim Contentlen

Dim beginpoint,endpoint

Maxpagelen=1000

content=Ubbcode(rs ("content"))

ArticleID=rs("ArticleID")

contentlen=len (content)

page=request. QueryString ("page")

If Contentlen<=maxpagelen Then

Response. Write Content

Else

If page="" Then

page=1

Else

page=Cint(page)

End If

If Pagenumber*maxpagelen<Contentlen Then

pagenumber pagenumber=pagenumber+1

End If

pagenumber=int(Contentlen/maxpagelen) +1

If page<1 then page=1

If page>pagenumber then page=pagenumber

If page=1 Then

beginpoint=1

Else

beginpoint=maxpagelen* (page-1) +1

End If

If page=pagenumber Then

EndPoint=Contentlen

Else

EndPoint=Maxpagelen*page

If EndPoint>=contentlen Then

EndPoint=Contentlen

End If

End If

content=Mid(content,beginpoint,endpoint-beginpoint)

Response. Write Content

Response. Write "<br>"

Response. Write "<br>"

Response. Write "<br>"

End If

For i=1 to PageNumber

Response. Write "<a href=articele. asp? ArticleID="& ArticleID &"&page="& I &"> "& I &"</a>"

Next

End Sub

%>   

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.