Example: ASP implementation of long article automatic pagination function code

Source: Internet
Author: User
Tags chr html tags strlen
Pagination | functional function c2u (myText)
Dim I
c2u = ""
For i = 1 to Len (MyText)
c2u = c2u & "& #x" & Hex (AscW (Mid (MyText, I, 1)) & ";"
Next
End Function

Function Cutstr (Str,strlen)
' Remove all HTML tags
Dim RE
Set re=new REGEXP
Re. IgnoreCase =true
Re. Global=true
Re. Pattern= "< (. [ ^>]*) > "
Str=re. Replace (str, "")
Set re=nothing
Dim L,t,c,i
L=len (str)
T=0
For I=1 to L
C=abs (ASC (str,i,1))
If c>255 Then
T=t+2
Else
T=t+1
End If
If T>=strlen Then
Cutstr=left (str,i) & "..."
Exit for
Else
Cutstr=str
End If
Next
Cutstr=replace (CUTSTR,CHR (10), "")
Cutstr=replace (CUTSTR,CHR (13), "")
End Function

Function converttowide (str)
Dim strlen
Dim position
Dim Convertstr
If IsNull (str) Then
Converttowide=str
Else
Position=1
Strlen=len (str)
For I=1 to Strlen
convertstr=convertstr+ "& #x" +hex (AscW (Mid (str,position,1)) + ";"
Position=position+1
Next
Converttowide=convertstr
End If
End Function

Dim Topicx,usernamex,addtimex,logtextx,ispassword
' Get ID number
Articleid=request ("ArticleID")
' Write execution statement
strSQL = "SELECT * from article where articleid=" &articleid& ""
' Connect the function above
Logtextx=cutstr (RS ("content"), 5000)
' Start paging
Dim page,pagelength,clength,pagecount,wen,a
If Request ("page") <> "then page = CLng (Request (" page ")
Pagelength = 80
Clength = Len (LOGTEXTX)
PageCount = Int (clength/pagelength) + 1
If page < 1 or IsNull (page) Then page = 1
If page > PageCount Then page = PageCount
If Page=1 Then
A=1
ElseIf Page>1 Then
A= (Page-1) *pagelength
End If
Wen=mid (Logtextx,a,pagelength)
' Judge
If page= "" or page=1 Then
' Start displaying content
Response.Write (C2u ("Content:")) ' www.w3sky.com
End If
Response.Write (Converttowide (Wen))
Response.Write "<br/>"
' Response.Write (Converttowide ("Word of the article:")) & Clength & "<br/>"
Response.Write (C2u ("This article is divided into")) & PageCount & (Converttowide ("page")) & "" &c2u ("Current" &Page& "page") & "<br/>"
If PageCount >1 and page <> 1 Then ' www.w3sky.com
Response.Write "1"
End If
Dim j
For J=page+1 to Page+10
If J <= PageCount-1 Then
Response.Write "" &j& ""
End If
Next
If PageCount >1 and Page <> PageCount Then
Response.Write "<a href="/"showarticle.asp?articleid=" &articleid& "&page=" &PageCount& "" " > "&PageCount&" </a><br/> "
End If
' End

The above code executes on WIN2000+IIS5, WIN2003+IIS6



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.