?? turnpage.asp
字號:
<%
'+++++++++++++++++++++++++++++++++++++
'◆模塊名稱: 公共翻頁模塊
'◆文 件 名: TurnPage.asp
'◆傳入參數: Rs_tmp (記錄集), PageSize (每頁顯示的記錄條數)
'◆輸 出: 記錄集翻頁顯示功能
'調用方法:
' 1、在程序開始或要使用翻頁的地方包含翻頁模塊文件;
' 2、定義變量:RowCount,每頁顯示的記錄條數
' 3、調用翻頁過程:Call TurnPage(記錄集,RowCount)
' 4、在Do While 循環輸出記錄集的條件中加上" RowCount > 0 " 條件
' 5、在循環結束 "Loop前" 加上: RowCount = RowCount - 1
'+++++++++++++++++++++++++++++++++++++
Sub TurnPage(ByRef Rs_tmp,PageSize) 'Rs_tmp 記錄集 ; PageSize 每頁顯示的記錄條數;
Dim TotalPage '總頁數
Dim PageNo '當前顯示的是第幾頁
Dim RecordCount '總記錄條數
Rs_tmp.PageSize = PageSize
RecordCount = Rs_tmp.RecordCount
TotalPage = INT(RecordCount / PageSize * -1)*-1
PageNo = Request.QueryString ("PageNo")
'直接輸入頁數跳轉;
If Request.Form("PageNo")<>"" Then PageNo = Request.Form("PageNo")
'如果沒有選擇第幾頁,則默認顯示第一頁;
If PageNo = "" then PageNo = 1
If RecordCount <> 0 then
Rs_tmp.AbsolutePage = PageNo
End If
'獲取當前文件名,使得每次翻頁都在當前頁面進行;
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
'取得當前的文件名稱,使翻頁的鏈接指向當前文件;
fileName = Mid(fileName,postion)
%>
<table border=0 width=100% height="25">
<tr>
<td align=left> 總頁數:<font color=#ff3333><%=TotalPage%></font>頁
當前第<font color=#ff3333><%=PageNo%></font>頁</td>
<td align="right">
<%If RecordCount = 0 or TotalPage = 1 Then
Response.Write "首頁 | 前頁 | 后頁 | 末頁"
Else%>
<a href="<%=fileName%>?PageNo=1">首頁</a> |
<%If PageNo - 1 = 0 Then
Response.Write "前頁 |"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo-1%>">前頁</a> |
<%End If
If PageNo+1 > TotalPage Then
Response.Write "后頁 |"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo+1%>">后頁</a> |
<%End If%>
<a href="<%=fileName%>?PageNo=<%=TotalPage%>">末頁</a>
<%End If%></td>
<td width=95 align="right">
<%
'If TotalPage = 1 Then
'Response.Write"轉到第<input type=text name=PageNo size=3 readonly disabled style=background:#d3d3d3> "
'Else
'Response.Write"<input type=text name=PageNo size=3 value='' title=請輸入頁號,然后回車>頁"
'End If%>
<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
<%
dim ii
for ii = 1 to TotalPage
%>
<option value="<%=fileName%>?PageNo=<%=ii%>" <%if cstr(ii)=cstr(pageno) then%>selected<%end if%>>第<%=ii%>頁</option>
<%
next
%>
</select>
</td>
</tr>
</table>
<%End Sub%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -