Tutorials to .com

Tutorials to .com » Asp » Encoding » ASP paging function

ASP paging function

Print View , by: iSee ,Total views: 9 ,Word Count: 663 ,Date: Tue, 2 Jun 2009 Time: 8:22 PM

Function ExportPageInfo (ByRef rs, curpage, i, LinkFile)
Dim retval, j, pageNumber, BasePage

retval = "first" & curpage & "page / Total" & rs.pagecount & "page"
retval = retval & "Page" & i & "Article / total" & rs.recordcount & "Article"

If curpage = 1 Then
retval = retval & "Home page"
Else
retval = retval & "<a href='" & LinkFile & "page=1'> Home </ a> <a href='" & LinkFile & "page=" & cstr(curpage-1) & "'> ago page </ a> "
End If
If curpage = rs.pagecount Then
retval = retval & "at the end of page after page"
Else
retval = retval & "<a href='" & LinkFile & "page=" & cstr(curpage + 1) & "'> after the page </ a> <a href = '" & LinkFile & "page =" & cstr (rs.pagecount) & " '> at the end of page </ a>"
End if

retval = retval & "<br>"
BasePage = (curpage \ 10) * 10
If BasePage> 0 Then retval = retval & "<a href='" & LinkFile & "page=" & (BasePage-9) & "'> <<</ a>"
For j = 1 to 10
pageNumber = BasePage + j
If PageNumber> rs.pagecount Then Exit For
If pageNumber = Cint (curpage) Then
retval = retval & "<font color='#FF0000'>" & pageNumber & "</ font>"
Else
retval = retval & "<a href='" & LinkFile & "page=" & pageNumber & "'>" & pageNumber & "</ a>"
End If
Next
If rs.pagecount> BasePage Then retval = retval & "<a href='" & LinkFile & "page=" & (BasePage + 11) & "'>>> </ a>"

ExportPageInfo = retval
End Function

Apply

<%
adoPageRS.open "SELECT * FROM news ORDER BY addtime DESC", conn, 1, 1
if err.number <> 0 then
response.write "Database operation failed:" & err.description
else
if adoPageRS.eof and adoPageRS.bof then
response.write "no records"
else
%>
<div align="center">
<center>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr class="big">
<td width="60%"> news headlines </ td>
<td width="25%" align="center"> date </ td>
<td width="15%" align="center"> operation </ td>
</ tr>
<%
adoPageRS.pagesize = 10
adoPageRS.absolutepage = curpage
for i = 0 to 9
%>
<tr>
<td> <% = adoPageRS ( "title")%> </ td>
<td align="center">
<% = AdoPageRS ( "addtime")%>
</ td>
<td align="center"> <a href = 'newsman.asp? action = edit & id = <% = adoPageRS ( "id ")%>'> Editor </ a>
<a href = 'javascript: confirmDel (<% = adoPageRS ( "id") %>)'> delete </ a> </ td>
</ tr>
<%
adoPageRS.movenext
if adoPageRS.eof then
i = i + 1
exit for
End If
next
%>
<tr align="center">
<td colspan="3">
<% = ExportPageInfo (adoPageRS, curpage, i, "Newsman.asp?")%>
</ td>
</ tr>
</ table>
</ center>
</ div>


Asp Script encoding Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.