Using Dreamweaver and ASP to realize the reference of paging technology

Source: Internet
Author: User
Tags dreamweaver

Today a little excited, want to "on the use of dw+asp to achieve the paging technology reference" to share with the dw+asp to do the Web page friends. Remove only "first page, previous page, next page, last page" of the Little Pain

The final display of this effect is: Nth page [total * page] <<1 2 3 4 5 6 7 8 9 >>.

When you use dw+asp as a Web page, after you bind the recordset, the following code appears immediately in the code page:

<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_数据库名_STRING
Recordset1.Source = "SELECT * FROM 表名"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>

Now we're going to make some changes to the code, please change it to the following code in the code:

<%
Dim I
Dim RPP
Dim PageNo
I=1
Rpp=50
Pageno=cint (Request ("PageNo"))
' That's the new insertion,
Dim Recordset1
Dim recordset1_numrows
Set Recordset1 = Server.CreateObject ("ADODB. Recordset ")
recordset1.activeconnection = mm_ database name _string
Recordset1.source = "SELECT * From Database name"
Recordset1.cursortype = 1 ' Change 0 of the above code to 1.
Recordset1.cursorlocation = 2
Recordset1.locktype = 1
Recordset1.open ()
recordset1_numrows = 0 ' again on the next line of this row, start adding the following code:
Recordset1.pagesize=rpp
If pageno<=0 Then pageno=1
If Pageno>recordset1.pagecount Then Pageno=recordset1.pagecount
Recordset1.absolutepage=pageno
Sub Showpageinfo (Tpagecount,cpageno)
Response.Write "&cPageNo&" page [Total &tPageCount& page]
End Sub
Sub Showpagenavi (Tpagecount,cpageno)
If cpageno<1 Then cpageno=1
If tpagecount<1 Then tpagecount=1
If Cpageno>tpagecount Then Cpageno=tpagecount
Dim Navilength
navilength=10 ' navilength: Number of digital links displayed
Dim I,startpage,endpage
Startpage= (cpageno\navilength) *navilength+1
If (Cpageno Mod navilength) =0 Then startpage=startpage-navilength
Endpage=startpage+navilength-1
If Endpage>tpagecount Then Endpage=tpagecount
If startpage>1 Then
Response.Write "<a class=" "Pagenavi" "href=" "? Pageno= "& (cpageno-navilength) &" "><<</a>"
Else
Response.Write "<font color=" "#CCCCCC" "><<</font>"
End If
For I=startpage to EndPage
If I=cpageno Then
Response.Write "<b>" &I& "</b>"
Else
Response.Write "<a class=" "Pagenavi" "href=" "? Pageno= "& I &" ">" & I & "</a>"
End If
If i<>tpagecount Then Response.Write "&nbsp;"
Next
If Endpage<tpagecount Then
Response.Write "<a class=" "Pagenavi" "href=" "? Pageno= "& (cpageno+navilength) &" ">>></a>"
Else
Response.Write "<font color=" "#CCCCCC" ">>></font>"
End If
End Sub
%>

In the code above: RPP: Specifies the number of record bars to display per page. That is, each page displays several data.

Navilength: The number of digital links displayed, that is, 10 of the 1 2 3...10 connection number.

To display all connected pages (number), you can set it to: Navilength=tpagecount.

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.