谁给我一个ASP分页代码?
谁给我一个ASP分页代码?最简单的那种就行只要能读取首页上页下页尾页当前第几页共几页这种就行带注释本人新手!谢谢上分说话别嫌少?...
谁给我一个ASP分页代码? 最简单的那种就行
只要能读取 首页 上页 下页 尾页 当前第几页 共几页 这种就行
带注释 本人新手 !谢谢 上分说话 别嫌少? 展开
只要能读取 首页 上页 下页 尾页 当前第几页 共几页 这种就行
带注释 本人新手 !谢谢 上分说话 别嫌少? 展开
展开全部
'***************************分页代码**************
Sub PageControl(iCount,pagecount,page,table_style,font_style)
Dim query, a, x, temp
Page_Action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
query = Split(Request.ServerVariables("QUERY_STRING"), "&")
For Each x In query
a = Split(x, "=")
If StrComp(a(0), "page", vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next
Response.Write("<table " & Table_style & ">" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & Page_Action & "?" & temp & "Page='+ this.page.value;return false;""><TR>" & vbCrLf )
Response.Write("<TD align=right>" & vbCrLf )
Response.Write(font_style & vbCrLf )
if page<=1 then
Response.Write ("首页 " & vbCrLf)
Response.Write ("上一页 " & vbCrLf)
else
If Action<>"" and Key<>"" then
Response.Write("<A HREF=" & Page_Action & "?Action="&Action&"&Key="&Key&"&Page=1>首页</A> " & vbCrLf)
Response.Write("<A HREF=" & Page_Action & "?Action="&Action&"&Key="&Key&"&Page=" & (Page-1) & ">上一页</A> " & vbCrLf)
Else
Response.Write("<A HREF=" & Page_Action & "?" & temp & "Page=1>首页</A> " & vbCrLf)
Response.Write("<A HREF=" & Page_Action & "?" & temp & "Page=" & (Page-1) & ">上一页</A> " & vbCrLf)
End If
end if
if page>=pagecount then
Response.Write ("下一页 " & vbCrLf)
Response.Write ("尾页 " & vbCrLf)
else
If Action<>"" and Key<>"" then
Response.Write("<A HREF=" & Page_Action & "?Action="&Action&"&Key="&Key&"&Page="&(Page+1)&">下一页</A> " & vbCrLf)
Response.Write("<A HREF=" & Page_Action & "?Action="&Action&"&Key="&Key&"&Page=" & pagecount & ">尾页</A> " & vbCrLf)
Else
Response.Write("<A HREF=" & Page_Action & "?" & temp & "Page=" & (Page+1) & ">下一页</A> " & vbCrLf)
Response.Write("<A HREF=" & Page_Action & "?" & temp & "Page=" & pagecount & ">尾页</A> " & vbCrLf)
End If
end if
Response.Write(" 页次:<font color=red>" & page & "</font>/" & pageCount & "页" & vbCrLf)
Response.Write(" 共有<font color=red>" & iCount & "</font>条信息" & vbCrLf)
Response.Write(" 转到" & "<INPUT TYEP=TEXT NAME=page SIZE=1 class=bottom Maxlength=5 VALUE=" & page & ">" & "页" & vbCrLf & "<INPUT type=submit style=""font-size: 9pt"" value=GO class=bottom>")
Response.Write("</TD>" & vbCrLf )
Response.Write("</TR></form>" & vbCrLf )
Response.Write("</table>" & vbCrLf )
End Sub
=======================================
在你需要分页调用的地方使用:
<% Call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")%>
=======================================
在SQL语句后面补充:(rs.open sql,conn,1,1)下面
if Rs.recordcount=0 then
response.write("<tr><td> </td><td> </td></tr>")
else
Rs.PageSize =20
iCount=Rs.RecordCount
iPageSize=Rs.PageSize
maxpage=Rs.PageCount
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
Rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if
================================================
不清楚可以给我留言
Sub PageControl(iCount,pagecount,page,table_style,font_style)
Dim query, a, x, temp
Page_Action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
query = Split(Request.ServerVariables("QUERY_STRING"), "&")
For Each x In query
a = Split(x, "=")
If StrComp(a(0), "page", vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next
Response.Write("<table " & Table_style & ">" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & Page_Action & "?" & temp & "Page='+ this.page.value;return false;""><TR>" & vbCrLf )
Response.Write("<TD align=right>" & vbCrLf )
Response.Write(font_style & vbCrLf )
if page<=1 then
Response.Write ("首页 " & vbCrLf)
Response.Write ("上一页 " & vbCrLf)
else
If Action<>"" and Key<>"" then
Response.Write("<A HREF=" & Page_Action & "?Action="&Action&"&Key="&Key&"&Page=1>首页</A> " & vbCrLf)
Response.Write("<A HREF=" & Page_Action & "?Action="&Action&"&Key="&Key&"&Page=" & (Page-1) & ">上一页</A> " & vbCrLf)
Else
Response.Write("<A HREF=" & Page_Action & "?" & temp & "Page=1>首页</A> " & vbCrLf)
Response.Write("<A HREF=" & Page_Action & "?" & temp & "Page=" & (Page-1) & ">上一页</A> " & vbCrLf)
End If
end if
if page>=pagecount then
Response.Write ("下一页 " & vbCrLf)
Response.Write ("尾页 " & vbCrLf)
else
If Action<>"" and Key<>"" then
Response.Write("<A HREF=" & Page_Action & "?Action="&Action&"&Key="&Key&"&Page="&(Page+1)&">下一页</A> " & vbCrLf)
Response.Write("<A HREF=" & Page_Action & "?Action="&Action&"&Key="&Key&"&Page=" & pagecount & ">尾页</A> " & vbCrLf)
Else
Response.Write("<A HREF=" & Page_Action & "?" & temp & "Page=" & (Page+1) & ">下一页</A> " & vbCrLf)
Response.Write("<A HREF=" & Page_Action & "?" & temp & "Page=" & pagecount & ">尾页</A> " & vbCrLf)
End If
end if
Response.Write(" 页次:<font color=red>" & page & "</font>/" & pageCount & "页" & vbCrLf)
Response.Write(" 共有<font color=red>" & iCount & "</font>条信息" & vbCrLf)
Response.Write(" 转到" & "<INPUT TYEP=TEXT NAME=page SIZE=1 class=bottom Maxlength=5 VALUE=" & page & ">" & "页" & vbCrLf & "<INPUT type=submit style=""font-size: 9pt"" value=GO class=bottom>")
Response.Write("</TD>" & vbCrLf )
Response.Write("</TR></form>" & vbCrLf )
Response.Write("</table>" & vbCrLf )
End Sub
=======================================
在你需要分页调用的地方使用:
<% Call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")%>
=======================================
在SQL语句后面补充:(rs.open sql,conn,1,1)下面
if Rs.recordcount=0 then
response.write("<tr><td> </td><td> </td></tr>")
else
Rs.PageSize =20
iCount=Rs.RecordCount
iPageSize=Rs.PageSize
maxpage=Rs.PageCount
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
Rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if
================================================
不清楚可以给我留言
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询