10 Days Learning ASP Tenth Day [ASP Tutorial Foundation Series]

Source: Internet
Author: User
Tags definition contains mdb database modify

Learning purposes: Paging technology, summary

The last day of today we learn a little bit more difficult in the ASP page paging technology, after all, when we have n records when we can not put all the records in a page inside it.
<%
Exec= "SELECT * FROM Test"
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open exec,conn,1,1
Rs. Pagesize=3
Pagecount=rs. PageCount
Page=int (Request. QueryString ("page"))
If Page<=0 then page=1
If request. QueryString ("page") = "" Then page=1
Rs. Absolutepage=page
%>
Rs.pagesize set a page to display the number of records, PageCount is our own definition of a variable, Rs.pagecount is the number of records, page is our own definition of a variable, our next page of the link can be set to list.asp? Page=<%=page+1%&gt, the next page of the link can be set to List.asp?page=<%=page-1%&gt, so that when the link is pressed to call the page itself, page this variable is +1 or 1, Finally we let rs.absolutepage (the current page) as page page on it.
If request. QueryString ("page") = "" Then page=1, the function of this sentence is that we open the list.asp when we do not follow the page variable, automatically set to page=1, to prevent errors, and when we if....then ... The end if can be omitted when placed on a line. is paging not difficult?
Here's a special case:
If page=1 and not page=pagecount, there is no previous page at this time, but there is a next page
ElseIf Page=pagecount and not page=1, this time there is no next page, but there is a previous page
ElseIf page<1, there's no record at this time.
ElseIf Page>pagecount Then, there's no record at this time.
ElseIf page=1 and Page=pagecount, this time there is no previous page, no next page
Else, this time there is a previous page, also has the next page.
The following section shows 1 to n pages, and each number after clicking on the number of pages represented in the code, very common OH.
<%for I=1 to Pagecount%>
<a href= "List.asp?page=<%=i%>" ><%=i%></a><%next%>
For....next is the cycle starting at I=1, and the cycle is added 1 to PageCount.

Finally, my example contains a simple ASP program, but the function of everything, is the essence of ASP, every ASP large program contains it.
add.htm Add Record page
add.asp Increase record operation
Conn.asp Database Links
del.asp Delete Record operation
Modify.asp Modify Record page
Modifysave.asp Modify record operations
List.asp This is the core of this program, through this page to achieve the record add, modify, delete.
Test.mdb database, which has aa,bb two fields: AA numeric type can only accept numbers, BB is character type.

OK, 10 days to the end of today, I think this tutorial is to let everyone get started, we feel that writing is not to blame will not be able to beginners and masters are taking care of it, and finally I would like to say that today's example is the essence of ASP, we must study hard, through the program, you will find that you will be ASP. Thank you for your support! We have a problem can be in my forum message, I hope we help webmaster more publicity This site, paste this site also invited the article famous source, thank you for your cooperation.



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.