<Script language = VBScript runat = Server>
'*************************************** *********************************
'Script compont Object Model
'Design for Active Server Pages
'
'Copyright 2004 Version 2.0
'Made by Yin Shuguang
'*************************************** *********************************
Function createcpagenavbar ()
Set createcpagenavbar = new cpagenavbar
End Function
Class cpagenavbar
Public splitsize 'size displayed by PAGE
Public pnwidth
Public pnalign
Public plwidth' table width
Public plalign table alignment
Private pagesize
Private recordcount 'Total number of records]
Private pagecount 'total page count
Private currentpage 'current page number
Private splitcount 'Total number of pages displayed
Private currentsplit 'current page number
'================================================ ======================================
Private sub class_initialize 'setup initialize event.
Splitsize = 10
Pnwidth = "100%"
Pnalign = "right"
Plwidth = "100%" // table width
Plalign = "right" // table alignment
Pagesize = 0
Recordcount = 0
Currentpage = 1
Pagecount = 1
Splitcount = 1
Currentsplit = 1
End sub
Private sub class_terminate 'setup terminate event.
End sub
Public sub initpagenavbar (byval ipagesize, byval irecordcount)
Pagesize = CINT (ipagesize)
Recordcount = clng (irecordcount)
Pagecount = fix (recordcount/pagesize) + 1
Splitcount = fix (pagecount/splitsize) + 1
End sub
Public Function getcurrentpage ()
'On error resume next
Dim pageno
Pageno = trim (request. querystring ("_ page_no _"))
'If no page is selected, the first page is displayed by default;
If (not isnumeric (pageno) or pageno = "") then
Pageno = 1
End if
Currentpage = clng (pageno)
If (currentpage <1) then
Currentpage = 1
End if
If (currentpage> pagecount) then
Currentpage = pagecount
End if
Currentsplit = fix (currentpage/splitsize) + 1
Getcurrentpage = currentpage
End Function
Public Function pldisplay ()
Dim strbuilder, P, itmp
Strbuilder = ""
'The first group is 0th
Strbuilder = strbuilder + "<Table border = '0' cellpadding = '0' cellspacing = '0 '"
Strbuilder = strbuilder + "width = '" & plwidth & "'align ='" & plalign & "'>"
Strbuilder = strbuilder + "<tr>"
Strbuilder = strbuilder + "<TD valign = 'middle' align = 'right'> pagination :"
If (currentsplit = 1) then
Strbuilder = strbuilder + "<font face = 'webstring' color = '# ff0000'> 9 </font>"
Strbuilder = strbuilder + "<font face = 'webstring' color = '# ff0000'> 7 </font>"
Else
Strbuilder = strbuilder + "<a href = '? _ Page_no _ = 1 'title = 'homepage'> <font face = 'webline'> 9 </font> </a>"
Strbuilder = strbuilder + "<a href = '? _ Page_no _ = "& CSTR (CurrentSplit-2) * splitsize) &" 'title = 'upper "& CSTR (splitsize) & "page '> <font face = 'webstring'> 7 </font> </a>"
End if
Strbuilder = strbuilder + "<B>"
'Paging list
Itmp = (CurrentSplit-1) * splitsize + 1
For I = itmp to (itmp + SplitSize-1)
If (I = currentpage) then
Strbuilder = strbuilder + "<font color = '#000000'>" & CSTR (I) & "</font>"
Else
Strbuilder = strbuilder + "<a href =? _ Page_no _ = "& CSTR (I) &" Title = 'Go to: page "& CSTR (I) &"> "& CSTR (I) & "</a>"
End if
If (I> = pagecount) then
Exit
End if
Next
Strbuilder = strbuilder + "</B>"
'Display the next 10 pages
If (currentsplit <splitcount) then
Strbuilder = strbuilder + "<a href = '? _ Page_no _ = "& CSTR (currentsplit) * splitsize) & "'title = 'Next ten page'> <font face = 'webline'> 8 </font> </a>"
Strbuilder = strbuilder + "<a href =? _ Page_no _ = "& CSTR (pagecount) &" Title = 'tail'> <font face = 'webline' >:</font> </a>"
Else
Strbuilder = strbuilder + "<font face = 'webstring' color = '# ff0000'> 8 </font>"
Strbuilder = strbuilder + "<font face = 'webstring' color = '# ff0000' >:</font>"
End if
Strbuilder = strbuilder + "</TD> </tr> </table>"
Response. Write (strbuilder)
End Function
Public Function pndisplay ()
Dim strbuilder, nextpageno
Strbuilder = ""
Strbuilder = strbuilder + "<Table border = '0' cellpadding = '0' cellspacing = '0 '"
Strbuilder = strbuilder + "width = '" & pnwidth & "'align ='" & pnalign & "'>"
Strbuilder = strbuilder + "<tr>"
Strbuilder = strbuilder + "<TD valign = 'middle'> page times: [<B>" & CSTR (currentpage) & "</B>/<B>" & CSTR (pagecount) & "</B>] Page per page [<B>" & CSTR (pagesize) & "</B>] Total number of records: [<B>" & CSTR (recordcount) & "</B>] </TD>"
Strbuilder = strbuilder + "<TD align = 'right'>"
If (CINT (currentpage)> 1) then
Nextpageno = CINT (currentpage)-1
Strbuilder = strbuilder + "[<a href =? _ Page_no _ = "& CSTR (nextpageno) &" Title = 'Go to previous page'> previous page </a>]"
End if
If (CINT (currentpage) <CINT (pagecount) then
Nextpageno = CINT (currentpage) + 1
Strbuilder = strbuilder + "[<a href =? _ Page_no _ = "& CSTR (nextpageno) &" Title = 'go to next page'> next page </a>]"
End if
Strbuilder = strbuilder + "</TD> </tr> </table>"
Response. Write (strbuilder)
End Function
End Class
</SCRIPT>