ASP news pagination, will be a long article pagination, generate static page _ Application Skills

Source: Internet
Author: User
Tags chr
The last time I was a friend from Csdn, I copied it. The original text is as follows
===========================
The use of statistical articles, and then reached a certain number of words on the truncation of output, but the content of the page will be in a baffling place truncated, not very friendly.
Very simply, find the following symbol near the place you want to truncate:
;'”?。!;'".!
If there is a <p> or <br> on the back page. The main is to study the format of the article.
<%
If Request.ServerVariables ("Content_length") > 0 Then
Content = Request.Form ("textarea1") pagelength = 1000 ' words per page
Clength = Len (content)
PageCount = Int (clength/pagelength) + 1 ' calculates the number of pages Dim Pagearray
ReDim Pagearray (PageCount) seperator = Array (CHR), Chr (10), ". ","! ","? ","; ",", "," "," "") ' separator pagearray (0) = 0
Pos = 0
For j=0 to UBound (seperator)
Pos = InStr (Pagearray (i) +900,content,seperator (j)) ' Pagearray (i) +900 the location is 100 words, 1-999 adjustable
While Pos > 0 and Pos < (i+1) *pagelength and pos > I*pagelength
Pagearray (i) = Pos
Pos = InStr (Pos+pagelength,content,seperator (J))
Wendif Pagearray (i) > 0 Then
Response.Write "0:i¦" &pagearray (i) & "<br>" &j& ": J" &seperator (j) & "<br>"
j = j + UBound (seperator) + 1
End If
Nextfor I=1 to PageCount-1
Pagearray (i) = 0
Pos = 0
For j=0 to UBound (seperator)
Pos = InStr (Pagearray (I-1) +950,content,seperator (j))
While Pos > 0 and Pos < (i+1) *pagelength and pos > I*pagelength
Pagearray (i) = Pos
Pos = InStr (Pos+pagelength,content,seperator (J))
Wend
If Pagearray (i) > 0 Then
Response.Write i& ": i¦" &pagearray (i) & "<br>" &j& ": J" &seperator (j) & "<br>"
j = j + UBound (seperator) + 1
End If
Next
Nextoutput = Mid (Content,1,pagearray (0))
Output = replace (OUTPUT,CHR (), <br>)
Response.Write "<br><br> 1th paragraph <br>"
Response.Write Outputfor I=1 to PageCount-2
Output = Mid (Content,pagearray (i-1) +1,pagearray (i)-pagearray (i-1))
Output = replace (OUTPUT,CHR (), <br>)
Response.Write "<br><br> section" &i+1& "paragraph <br>"
Response.Write Output
Next ' the last paragraph of the output is not written else
%>
<form action= "" Method=post id=form1 name=form1>
<textarea rows=70 cols=120 id=textarea1 name=textarea1>
</TEXTAREA>
<input type= "Submit" value= "Submit" Id=submit1 name=submit1>
</FORM>
<%end if%>


---------------------------------------------------------------

Defines the length of each page MaxLength
Text total length Totallength
Scan a hard return at the end of each section in an article
and calculate the length of the place
Once more than MaxLength is divided into the first page
Repeat the previous operation before removing this hard return.
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.