ASP news pagination: pagination of an article that is too long to generate a static page

Source: Internet
Author: User

I copied the answer from a friend in CSDN last time. The original text is as follows:
======================================
When the number of words in an article is counted and reaches a certain number of words, the output will be truncated, but the page content will be truncated in some inexplicable places, which is not very friendly.
It is easy to find the following symbol near the place to be truncated:
;'"?.!; '".!
If <p> or <br> exists, the page is displayed. It is mainly to study the document format.
<%
If Request. ServerVariables ("Content_Length")> 0 then
Content = Request. Form ("textarea1") PageLength = 1000 'words per page
CLength = Len (content)
PageCount = Int (Clength/PageLength) + 1' calculate the number of pages dim PageArray
Redim PageArray (PageCount) Seperator = Array (chr (13), 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 is near 100 words, adjustable from 1
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 found" & 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 found" & 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 (13), "<br> ")
Response. Write "<br> paragraph 1st <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 (13), "<br> ")
Response. Write "<br> section" & I + 1 & "<br>"
Response. Write output
Next 'the output of the last segment has not been written into 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
Total text length TotalLength
Scan the hard carriage return at the end of each segment in the article
And calculate the length.
If MaxLength is exceeded, it is split into the first page.
Delete the part before the press Enter.

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.