Long article page display with page breaks (ASP implementation)

Source: Internet
Author: User
Tags add end key split variable
Long article pages are displayed with page breaks, want to use ASP also realize this function, can find only according to the Word page pagination method, but this method has a bug, if your article content if there is UBB code, it is easy to cause in [code][/code] between paging, or simply put [ Code] is decomposed into [Co and de] so that the article displays an error.


The following steps will be fully implemented.

First step:

In accordance with the normal article system all the way down, the background of the article to add, the article search, and the detailed page of the article, are normal ways to exercise

, please refer to the relevant posts without any description. Just add the page break where you want it to be paged: ""

(Of course this symbol you can use, such as: [Page], &&&, ###, @@@., as long as it will not be in the article to normal display of the ground

Side to appear on the line. )
I used four pages, input page (index.asp), Input complete page (add.asp), Article List page (view.asp), article

Content page (display.asp), the first three are not processed pages, look at the picture below I think the average bird will do, the key is the last

A displasy.asp, all the code that implements pagination is here.

Step Two:

In the text of the content of the dynamic Data part of the hands and feet, the following is the Code and interpretation:

<%
' This is where you want to process the paging parameters that you receive to display the contents of the page
' The next two sentences are that if there is no page, let the variable pagenum take the value of the first page: 0
If Request ("page") = "" Then
Pagenum=0
' Otherwise assign the variable to the argument in the page that is passed, to display the other pages
Else
Pagenum=request ("page")
End If
%>
<%
' If you add the optional execute UBB code, you can add the following code
' RS (' Noubb ') is a field in the database about disabling UBB, 0 is disabled, and 1 is executing
If rs ("Noubb") =0 Then
' To avoid errors associated with the content of the article, use the Replace function to add a full angle to the front and back of the paging code.
' RS (' content ') is the text field in the database, where you add Ubb or disable UBB
Content=replace ((Unhtml (RS ("content")), "", "" "
Elseif rs ("Noubb") =1 Then
Content=replace ((Ubb (RS ("content")), "", "" "
End If
%>
<%
' This is the key.
' We use the Split function to separate the article into the variable content.
Contentstr=split (Content, "")
' In accordance with the variable that you have just obtained from the URL parameter to show that side, loop the page
For I=pagenum to Pagenum
%>
<!--here will be the content of the article body-->
<%=contentstr%>
<% Next%>

</td>
</tr>
<tr>
&LT;TD height= "class=" "ClassName" > This paper is divided into
<%
' Pagination place, with UBound (CONTENTSTR) to get the article is divided into several pages, note that this is starting from 0, so the total number of pages need to add 1
For p = 0 To UBound (CONTENTSTR)

' Link or this page, but after the article ID parameter also add a paging parameter: page
%>
<a href= "Display.asp?id=<%=rsquest" ("ID")%>&page=<%=p%> "class=" "><%=p+1%></a>
<% Next%> Page



Very simple, if the comments are deleted, only 15 lines of code, but also to be processed, so that it can have the previous page, the next page and the current page outstanding features on the perfect.

have been tested, unless the article appears that page break, otherwise all types will not go wrong, of course, can increase the number of such as:, and then six "" in the article appears all right, but more than six will be pagination, select a good page break on it



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.