asp网页分页代码(web前端分页)
admin 发布:2022-12-23 08:45 87
本篇文章给大家谈谈asp网页分页代码,以及web前端分页对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
如何实现ASP分页功能
我来试试看:
!--#include file="conn.asp"--
%
set rsc=server.createobject("adodb.recordset")
sqlc="select * from news where class='"rs("class")"' order by id desc"
rsc.open sqlc,conn,1,1
Response.write "center"
rsc.PageSize = 10 'pagesize属性指定了每页要显示的记录条数
Page = CLng(Request("Page")) ’string型转化为long型
If Page 1 Then Page = 1
If Page rsc.PageCount Then Page = rsc.PageCount
If Page 1 Then
Response.Write "A HREF=emp1.asp?Page=1第一页/A�"
Response.Write "A HREF=emp1.asp?Page=" (Page-1) "上一页/A�"
End If
If Page rsc.PageCount Then
Response.Write "A HREF=emp1.asp?Page=" (Page+1) "下一页/A�"
Response.Write "A HREF=emp1.asp?Page=" rsc.PageCount "最后一页/A�"
End If
Response.write "页码:" Page "/" rsc.PageCount "/centertable border=1"
rsc.AbsolutePage = Page '把页码赋给absolutepage属性从而知当前页的首条记录号
For iPage = 1 To rsc.PageSize
%
tr
td width="574" bordercolor="#CCCCCC" class="classlist"div align="left" class="classlist"span class="classlist"a href="news.asp?id=%=rsc("id")%"%=rsc("title")%/a/span/div/td
td width="196" height="16" bordercolor="#CCCCCC" %=rsc("time")%/td
td width="112" height="16" bordercolor="#CCCCCC" %=rsc("by")%/td
%
rsc.MoveNext
If rsc.EOF Then Exit For
Next
%
/tr
tr
td colspan="2" /td
/tr
/table
br /
table width="100%" border="1" bordercolor="#FFFFFF"
tr
td width="100%" bordercolor="#CCCCCC"
td
/tr
/table
/div
/body
/html
%
rs.close
rsc.close
set rs=nothing
set rsc=nothing
conn.close
set conn=nothing
%
寻一ASP分页代码
%
'----------------------------------------
' 获取当前页带参数的地址
'----------------------------------------
Function Urladdress()
Dim uAddress,ItemUrl,Mitem,Get_Url,get_c,getstr
uAddress = CStr(Request.ServerVariables("SCRIPT_NAME"))
ItemUrl = ""
If (Request.QueryString "") Then
uAddress = uAddress "?"
For Each Mitem In Request.QueryString
If LCase(MItem)"page" and LCase(MItem)"pageno" then
ItemUrl = ItemUrl MItem "=" trim(Server.URLEncode(Request.QueryString(""MItem""))) ""
end if
Next
end if
Get_Url = uAddress ItemUrl
if LCase(right(Get_Url,3))"asp" then
Get_Url=left(Get_Url,len(Get_Url)-1)
end if
urladdress = Get_Url
if Instr(urladdress,"?")0 then
urladdress=urladdress""
Else
urladdress=urladdress"?"
end if
end function
'---------------------------------------------------------------
' 分页代码函数
' 参数: rscount:总条数,pagecount:总页数,pageno:当前页
'---------------------------------------------------------------
Function Pageshow(rscount,pagecount,pageno)
Dim TemplatePage,page2,s
TemplatePage = "div class=""page""共 " rscount " 条信息!--button确定/buttonspan页/spaninput name="""" type=""text"" /span跳转到第/span--" vbcrlf
if pageno=1 then
TemplatePage = TemplatePage " a href=""#""首页/a a href=""#""上一页/a " vbcrlf
else
TemplatePage = TemplatePage " a href="""urladdress"page=1""""首页/a " vbcrlf " a href="""urladdress"page=" pageno-1 """上一页/a " vbcrlf
end if
page2 = (pageno - (pageno mod 5)) / 5
if page2 1 then page2 = 0
for s = page2 * 5 - 1 to page2 * 5 + 5
if s 0 then
if s=cint(pageno) then
TemplatePage = TemplatePage " a class=""pagea pageselect"" href=""" urladdress "page=1""" s "/a" vbcrlf
else
if s=1 then
TemplatePage = TemplatePage " a class=""pagea"" href=""" urladdress "page=1""" s "/a" vbcrlf
else
TemplatePage = TemplatePage " a class=""pagea"" href=""" urladdress "page="s"""" s "/a" vbcrlf
end if
end if
if s = Pagecount then
exit for
end if
end if
next
if cint(pageno) = Pagecount then
TemplatePage = TemplatePage " a href=""#""下一页/a a href=""#""尾页/a" vbcrlf
else
TemplatePage = TemplatePage " a href=""" urladdress "page=" pageno+1 """下一页/a " vbcrlf " a href="""urladdress "page=" Pagecount"""尾页/a" vbcrlf
end if
TemplatePage = TemplatePage "span 共"pagecount"页/span/div"vbcrlf
Pageshow = TemplatePage
End function
%
ASP分页代码
tjpage = CLng(request.QueryString("page")) '转换成数值型
%if ipagers.pagecount then%
这里改成小于号,不然页码大于你最后一页时,这段代码也会失灵.
asp内容分页代码
我是这样分页的,确定能用,给你看看,看能否帮上你的忙
%
Dim currentpage,page_count,Pcount
dim totalrec,endpage
currentPage=request("page")
if currentpage="" then
currentpage=1
else
currentpage=clng(currentpage)
if err then
currentpage=1
err.clear
end if
end if
%
一下是连接数据库
%
set rs=server.CreateObject("adodb.recordset")
sql="select * from "你的表名"where "条件""
rs.open sql,conn,1,1
if not rs.eof then '1.判断是否有记录
rs.PageSize = 18 '每页18条记录
rs.AbsolutePage=currentpage
page_count=0
while (not rs.eof) and (not page_count =18)
for a=1 to rs.PageSize
page_count = page_count + 1
rs.movenext
if rs.eof then exit for
next
wend
Pcount=rs.PageCount
end if
%
分页开始
%
if currentpage 4 then
response.write "a href=""?page=1"[1]/a ..."
end if
if Pcountcurrentpage+3 then
endpage=currentpage+3
else
endpage=Pcount
end if
for i=currentpage-3 to endpage
if not i1 then
if i = clng(currentpage) then
response.write "font color=red["i"]/font"
else
response.write "a href=""?page="i"["i"]/a"
end if
end if
next
if currentpage+3 Pcount then
response.write "... a href=""?page="Pcount"["Pcount"]/a"
end if
%
asp代码分页
Function rsToPageHtml(rsPage,PageSize,rsUrl)
If rsPage.EOF Then
rsToPageHtml = "Nothing yet! Please check back later."
Exit Function
End If
Dim rsCount,PageCount,Page,sScriptName,strTemp
Dim tmpPage, intPage, allPage
rsCount = rsPage.RecordCount
rsPage.PageSize = PageSize
PageCount = rsPage.PageCount
Page = Request("Page")
if Page="" then
Page = 1
else
Page = Clng(Page)
end if
if Page 1 then Page = 1
If Page Pagecount Then Page = Pagecount
rsPage.AbsolutePage = Page
'sScriptName = Request.ServerVariables("SCRIPT_NAME")
if InstrRev(rsUrl,".asp?") 0 then
rsUrl = rsUrl "Page="
else
rsUrl = rsUrl "?Page="
end if
strTemp = ""
tmpPage = 10
intPage = Int((Page-1) / tmpPage)
allPage = Int(Pagecount / tmpPage)
If Page1 and intPage0 Then strTemp = strTemp "a href=""" rsUrl "1"" title=首页font face=webdings9/font/a "
If intPage0 Then strTemp = strTemp "a href=""" rsUrl ((intPage-1)*tmpPage+1) """ title=前十页font face=webdings7/font/a "
if page1 then strTemp = strTemp "a href=""" rsUrl page-1 """ title=""上一页""font face=""webdings""3/font/a "
If intPageallPage Then
For n=(intPage*tmpPage+1) To (intPage+1)*tmpPage
If n=Page Then
strTemp = strTemp " font color=redb" n "/b/font "
Else
strTemp = strTemp " a href=""" rsUrl n """b" n "/b/a "
End If
Next
Else
For n=(intPage*tmpPage+1) To Pagecount
If n=Page Then
strTemp = strTemp " font color=redb" n "/b/font "
Else
strTemp = strTemp " a href=""" rsUrl n """b" n "/b/a "
End If
Next
End If
if pagePageCount then strTemp = strTemp "a href=""" rsUrl page+1 """ title=""下一页""font face=""webdings""4/font/a "
If intPageallPage Then strTemp = strTemp "a href=""" rsUrl ((intPage+1)*tmpPage+1) """ title=后十页font face=webdings /font/a "
If PagePagecount and intPageallPage Then strTemp = strTemp "a href=""" rsUrl Pagecount """ title=末页font face=webdings:/font/a "
strTemp = strTemp " " PageCount " pages "" "rsCount" pics"
rsToPageHtml = strTemp
End Function
function ifspace(Name)
if Name"" then
ifspace=Name
else
ifspace="-"
end if
end function
asp分页代码
sub showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
dim n, i,strTemp,strUrl
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
strTemp= "table align='center'form name='showpages' method='Post' action='" sfilename "'trtd"
if ShowTotal=true then
strTemp=strTemp "共 b" totalnumber "/b " strUnit " "
end if
strUrl=JoinChar(sfilename)
if CurrentPage2 then
strTemp=strTemp "首页 上一页 "
else
strTemp=strTemp "a href='" strUrl "page=1'首页/a "
strTemp=strTemp "a href='" strUrl "page=" (CurrentPage-1) "'上一页/a "
end if
if n-currentpage1 then
strTemp=strTemp "下一页 尾页"
else
strTemp=strTemp "a href='" strUrl "page=" (CurrentPage+1) "'下一页/a "
strTemp=strTemp "a href='" strUrl "page=" n "'尾页/a"
end if
strTemp=strTemp " 页次:strongfont color=red" CurrentPage "/font/" n "/strong页 "
strTemp=strTemp " b" maxperpage "/b" strUnit "/页"
if ShowAllPages=True then
strTemp=strTemp " 转到:select name='page' size='1' onchange='javascript:submit()'"
for i = 1 to n
strTemp=strTemp "option value='" i "'"
if cint(CurrentPage)=cint(i) then strTemp=strTemp " selected "
strTemp=strTemp "第" i "页/option"
next
strTemp=strTemp "/select"
end if
strTemp=strTemp "/td/tr/form/table"
response.write strTemp
end sub
将上面的的参数改成你想要的参数就可以了
asp网页分页代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于web前端分页、asp网页分页代码的信息别忘了在本站进行查找喔。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
相关推荐
- 06-03常见刮刮乐代码含义(刮刮乐上的代码)
- 08-03派出所代码表(派出所代码表大全两位数)
- 07-05派出所的组织代码(派出所机构代码在哪查)
- 05-19酒店代码在那里(酒店代码是什么)
- 09-03网易云音乐代码(网易云音乐代码大全)
- 05-05怎么用代码下载视频(如何用代码下载文件)
- 08-01源代码查看答案(源代码怎么看答案)
- 09-22查看手机屏幕代码(手机查询屏幕代码)
- 08-22qq强行聊天代码(强制聊天器在线使用)
- 07-28网页代码怎么呼出(怎么样调出网页代码)
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接