ASP content paging Principle

Source: Internet
Author: User
Tags url example

In ASP, If You Want To pagination in a list, you can accept the parameters of the next page. Then, you can determine whether it is null or a number. Then, you can set how many data entries are displayed on each page, determine whether the page number is greater than the total page number...

What about inner pages? The inner page cannot be like this. The inner page can use the pagination symbol. For example, if {$ page $} is displayed on the page, how can this problem be determined?

For example, you wrote an article as follows:

In fact, you only click the Browse button when you Click Upload. This step will make you select a file. You have to monitor whether the value of the text box for uploading and browsing changes, if this parameter is changed, the form {$ page $} will be submitted to IFRAME, and then the returned value of IFRAME will be monitored. For example, 1 is returned after successful upload in your program, if the value is 1, the upload is successful. Otherwise, the upload fails. So how to listen to this IFRAME? You can use jquery's load () parameter or onload.

The first page is used until {$ page $}, and the second page appears until {$ page $, of course, if there is no paging symbol, whether to go straight to the end, there is no third page. Check the program code:

ASP code

1 dim content, page, content_tmp, page_count, outcontent 2 content = RS ("content") 3 page = trim (request. querystring ("page") 4 If page = "" Then page = 1 5'. Of course, you must determine whether the page is legal, for example, whether it is a correct number or not. 6 if instr (content, "{$ page $}")> 0 then' if it contains a paging symbol, 7 content_tmp = Split (content, "{$ page $ }") 'store the variables to split the content 8 page_count = ubound (content_tmp) + 1' so that page_count = is divided into several pages, here + 1 is used to prevent subscript errors 9 If page> page_count then page = page_count 'if the current page is greater than the total page, the current is equal to the total page 10 outcontent = content_tmp (page-1) 'Let the output variable = split the page-1 page in the content. For example, if you have two paging symbols, three pages are displayed, and content_tmp (0) is the first page, content_tmp (1) is the second page... 11 else12 outcontent = content 'if it does not contain a paging character, it is directly equal to 13 end if14 15 response. write (outcontent) 'output content

Then you can see the above ASP code?

Now, the content is output, but what is missing is the navigation after the pages in the inner pages. This is the best way to do this:

ASP code

1 dim ipage, URL 2 if page_count> 1 then' if the total page is greater than 1, the internal page navigation is displayed 3 response. write ("<div>") 4 for ipage = 1 to page_count 'loop. 5 If ipage = 1 then 6 url = ID &". in HTML "', the ID is your news ID. Here it is just a simulation, you can change 7 else 8 url = ID & "_" & ipage & "according to your own situation &". html "9 end if10 if ipage = thispage then11 response. write ("<strong style =" "color: # ff0000;" "> page" & ipage & "</strong>") 12 else13 response. write ("<a href =" "& URL &" Title = 'click to enter the page "& ipage &"> page "& ipage &" </> ") 14 end if15 next16 response. write ("</div>") 17 end if

Here, the page of an internal page is OK. Here is a static URL example. Of course, you need to change the URL based on your website requirements. For example, here is HTML/1.html. Here 1 is the article Id. If there is a second page, it is HTML/20.2.html. If you want to change the URL dynamically, it will be OK.

When it comes to paging, there are still automatic paging, for example, how many characters will be automatically paginated, but there will be n more judgments. For example, when you pagination, you can't tell people's pictures, right, what should I do if the 1,000th characters on your page are exactly a tag?

The automatic inner page is being studied. I will share it with you later!

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.