ASP long article with page break page display _ Application Tips

Source: Internet
Author: User

Note that [page] needs to remove the middle space because it repeats with the background paging of the cloud-dwelling community, so you add a space handle.

Just add a page break where you want it to be paged when the article is added: "[Page] (of course this symbol you can use, such as: [Page], &&&, ###, @@@., as long as it does not appear in the article to the normal display of the line. )
I used four pages, input page (index.asp), Input complete page (add.asp), Article List page (view.asp), Article content page (text.asp), the first three are not to deal with the page, look at the following introduction I think the general bird will do, the key is the last text.asp, all the implementation of pagination code here.
Step two: To
In the text of the content of the dynamic Data part of the hands and feet, the following is the Code and interpretation:

Copy Code code as follows:



' Here's the code to process the pagination


' For the sake of filtration insurance, we use the Replace function to add a full-width space before and after the paging code.


Mmtext=replace (RS ("contents"), "[Page]", "[Page]")


Mmftext=split (Mmtext, "[Page]")


' Use the UBound function to get the number of pages to be divided, noting that the subscript value starts at 0.


Contentnum=ubound (Mmftext)


PAGE=CLNG (Request ("page")


If Page<1 Then


Page=1


End If


' In order to look intuitive, we set the start page to 1, and then the total number of pages will add 1


If Page>contentnum+1 Then


Page=contentnum+1


End If


' The variable that is taken from the parameter in the URL to be displayed, loops through the page


For I=page to Page


Response.Write Mmftext (I-1)


Next


' List page pagination


If CInt (contentnum) >0 Then


If Page<>1 Then


Response.Write "<a href= ' text.asp?id=" &request ("id") & "&page=" &page-1& ">[last page]</a > "


End If


' Remember that the subscript is starting at 0, and we're going to start paging from 1, and we'll add a total of 1.


For P=1 to Contentnum+1


If Page=p Then


Response.Write "<a href= ' text.asp?id=" &request ("id") & "&page=" &p& "><font color=red >["&p&"]</font></a> "


Else


Response.Write "<a href= ' text.asp?id=" &request ("id") & "&page=" &p& ">[" &p& "]< /a> "


End If


Next


If Page<>contentnum+1 Then


Response.Write "<a href= ' text.asp?id=" &request ("id") & "&page=" &page+1& ">[next page]</a > "


End If


End If








The following is the article of other websites, we can also refer to the following.

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 to do all the way down, the background of the article to add, the article's search, and the detailed page of the article, are the general mode of operation, here without description, please refer to the relevant posts. 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 does not appear in the article to the normal display of 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 to deal with the page, look at the picture below I think the general bird will do, the key is the last displasy.asp, all the implementation of pagination code 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:


Copy Code code as follows:



<%


' 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 put the paging code "| | |" plus a full angle.


' 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>


<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.


has been tested, unless the article appears that page break, otherwise all types will not go wrong, of course, you can put | | | The number of increase, such as: | | | | |, and then six "|" The following in the article appears all right, but more than six will be paginated, choose a good page break on it

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.