Recommended: Multiple functions verify the same form Before submitting a form, we usually use client JS to verify its content. Usually, we write a function and call it in the onsumbit event, as follows: The following is the referenced content: <html><head&
Long article pages are displayed with page breaks. If you want to use ASP to implement this function, you can find that only the method of paging is based on the number of words. However, this method has a bug, that is, if there is UBB or HTML code in your article content, it can easily cause paging between [code] [/code], or simply breaking [code] into [co and de], so that the article will display errors.
The following steps will be fully implemented.
first step:
Follow the normal article system and continue to do it all the way. The article addition, article retrieval, and article detailed pages are all operated in a regular way. There is no description here, please refer to the relevant posts. Just add page breaks where you want it to paging when adding articles: |||
(Of course you can use this symbol at will, such as: [page], &&&, ###, @@@..., as long as it will not appear where the article is to be displayed normally.)
I used four pages, the input page (index.asp), the input completion page (add.asp), the article list page (view.asp), and the article content page (display.asp). The first three are pages that do not need to be processed. Looking at the picture below, I think ordinary birds will do it. The key is the last display.asp. All the codes that implement pagination are here.
Step 2:
Do some tricks in the dynamic data part of the article's main content. The following is the code and explanation:
| The following is the quoted content: <% 'The received paging parameters are processed here to display the content of the page 'The following two sentences are: If the parameter page is not passed, let the variable pageNum take the value of the first page: 0 If Request(page)= Then pageNum=0 'Otherwise, assign the variable as the parameters in the passed page to display other pages Else pageNum=Request(page) End if %> <% 'If you add optional execution UBB code, you can add the following code 'rs(NoUBB) is the field in the database about disabling UBB. 0 is disabled and 1 is execution. If rs(NoUBB)=0 then 'To avoid errors in connection with the article content, use the Replace function to add a full-width front and back of the pagination code||| 'rs(content) is the field of the main text in the database. Add UBB here 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 extract the article segments and save it into the variable content ContentStr=split(Content,|||) 'According to the variable that you want to display that page just obtained from the URL parameters, just loop to display a page For i=pageNum to pageNum %> <!--This will be the main content of the article--> <%=ContentStr %> <% Next %> </td> </tr> <tr> <td height=30 class=ClassName>This article is divided into <% 'In the page place, use ubund(ContentStr) to get the article into several pages. Note that it starts from 0, so the total number of pages needs to be added to 1. For p = 0 to ubund(ContentStr) 'The link is still this page, but the article ID parameter must be added with a pagination parameter: page %> <a href=display.asp?ID=<%=rsquest(ID)%>&page=<%=p%> class=><%=p 1%></a> <% Next %> Page |
It's very simple. If you delete all the comments, there will be only 15 lines of code. However, you still need to process it to make it have the functions highlighted by the previous page, the next page and the current page. It will be perfect.
I have tested that unless the page break appears in the article, there will be no errors in all types. Of course, you can increase the number of |||, for example: |||||, and it will be fine if the article appears below six, but more than six will be paginated. Just select a good page break.
Share: Talking about the copy of the object The following is the referenced content: <%Dim oConn,oRsSet oConn = Server.CreateObject(ADODB.Connection)Set ors = Server.CreateObject(ADODB.R