ASP 数字分页效果代码
2020-02-28 16:00:25来源:爱站网 阅读 ()
网页开发页面分页有度需要进行设置,然而有时候难免会疏漏,现在一般都会设置在页面的中间显眼的地方,下面是爱站技术频道小编带给大家的ASP 数字分页效果代码,希望对你有所帮助。
效果:
国外的核心代码:
?
<%
?'digg style pagination script in asp.. written by Moazam... http://www.moazam.com/2007/03/30/asp-digg-style-pagination-script/
?function getPaginationString(page, totalitems, limit, adjacents, targetpage)?
??'defaults
??if not isnumeric(adjacents) then adjacents = 1 end if
??if not isnumeric(limit) then? limit = 15 end if
??if not isnumeric(page) then page = 1 end if
??if targetpage = "" then targetpage = "/" end if
??margin = ""
??padding=""
??'other vars
??prev = page - 1?????????'previous page is page - 1
??nextPage = page + 1?????????'nextPage page is page + 1
??lastpage = Ceil(totalitems , limit)????'lastpage is = total items / items per page, rounded up.
??lpm1 = lastpage - 1????????'last page minus 1
??'?Now we apply our rules and draw the pagination object.
??'?We're actually saving the code to a variable in case we want to draw it more than once.
??pagination = ""
??if lastpage > 1 then
???pagination = pagination & "<div class=""pagination"""
???if margin <> "" OR padding <> "" then
????pagination = pagination &? " style="""
????if margin <> "" then
?????pagination = pagination &? "margin: margin"
????end if
????if padding <> "" then
?????pagination = pagination &? "padding: padding"
????end if
????pagination = pagination &? """"
???end if
???pagination = pagination &? ">"
???'previous button
???if page > 1 then
????pagination = pagination &? "<a href="""&targetpage&"&page="&prev&""">Prev</a>"
???else
????pagination = pagination &? "<span class=""disabled"">Prev</span>"?
???end if
???'pages?
???if lastpage < 7 + (adjacents * 2) then?'not enough pages to bother breaking it up
?
????for counter = 1 to lastpage
?????if counter = page then
??????pagination = pagination &? "<span class=""current"">"&counter&"</span>"
?????else
??????pagination = pagination &? "<a href="""&targetpage&""&"&page="&counter&""">"&counter&"</a>"
?????end if
????next?
???elseif lastpage >= 7 + (adjacents * 2) then?'enough pages to hide some
????'close to beginning only hide later pages
????if page < 1 + (adjacents * 3) then?
?????for counter = 1 to (4 + (adjacents * 2))-1
??????if counter = page then
???????pagination = pagination &? "<span class=""current"">"&counter&"</span>"
??????else
???????pagination = pagination &? "<a href="""&targetpage&"&page="&counter&""">"&counter&"</a>"
??????end if???
?????next
?????pagination = pagination &? "..."
?????pagination = pagination &? "<a href="""&targetpage&""&"&page="&lpm1&""">"&lpm1&"</a>"
?????pagination = pagination &? "<a href="""&targetpage&""&"&page="&lastpage&""">"&lastpage&"</a>"??
????'in middle hide some front and some back
????elseif lastpage - (adjacents * 2) > page AND page > (adjacents * 2) then
?????pagination = pagination &? "<a href="""&targetpage&"&page=1"">1</a>"
?????pagination = pagination &? "<a href="""&targetpage&"&page=2"">2</a>"
?????pagination = pagination &? "..."
?????for counter = (page - adjacents) to (page + adjacents)
??????if counter = page then
???????pagination = pagination &? "<span class=""current"">"&counter&"</span>"
??????else
???????pagination = pagination &? "<a href="""&targetpage&"&page="&counter&""">"&counter&"</a>"
??????end if
?????next
?????pagination = pagination &? "..."
?????pagination = pagination &? "<a href="""&targetpage&"&page="&lpm1&""">"&lpm1&"</a>"
?????pagination = pagination &? "<a href="""&targetpage&"page="&lastpage&""">"&lastpage&"</a>"??
????'close to end only hide early pages
????else
?????pagination = pagination &? "<a href="""&targetpage&"&page=1"">1</a>"
?????pagination = pagination &? "<a href="""&targetpage&"&page=2"">2</a>"
?????pagination = pagination &? "..."
?????for counter = (lastpage - (1 + (adjacents * 3))) To lastpage
??????if counter = page then
???????pagination = pagination &? "<span class=""current"">"&counter&"</span>"
??????else
???????pagination = pagination &? "<a href="""&targetpage&"&page="&counter&""">"&counter&"</a>"
??????end if
?????next
????end if
???end if
???'nextPage button
???if page < counter - 1 then
????pagination = pagination &? "<a href="""&targetpage&"&page="&nextPage&""">Next</a>"
???else
????pagination = pagination &? "<span class=""disabled"">Next</span>"
???end if
???pagination = pagination &? "</div>" & vbnewline
??end if
??getPaginationString = pagination
?end function
?function Ceil( dividend, divider)
??if (dividend mod divider) = 0 Then
???Ceil = dividend / divider
??ELSE
???Ceil = Int(dividend / divider) + 1
??End if
??? End function
?'test script code
?page = 1
?if request("page") <> "" then
??page=cint(request("page"))
?end if
?ps = getPaginationString(page, 1500, 15, 2, "pagination.asp?foo=bar")
?Response.Write("<br /><br /><br /><br /><br /><br /><br /><br />"&ps)
%>
?
完整打包代码:pagination(jb51.net).rar
?
?
看了有些头晕,还是看点简单的吧,asp与php思想差不多啊,参考了dedecms的修改方法
效果图:
核心代码:
?
ps=cint(pageno)-2???????????
? if ps<1 then???????????
? ps=1???????????
? end if
pe=clng(pageno)+5
if pe>mpage then pe=mpage
for i=ps to pe
if i=pageno then
lb=lb&"<strong>"&i&"</strong>"
else
lb=lb&"<a href=""/list/list_"&theid&"_"&i&".htm"">"&i&"</a>"
end if
next
?
完整代码:
?
pageno=cint(currentPage)
if cint(pageno)>1 then
lb=lb&"<a href=/list/list_"&theid&"_1.htm title=""首页"">首页</a>"
else
lb=lb&"<a href='#'>首页</a>"
end if
if cint(pageno)>1 and cint(pageno) then
lb=lb&"<a href=/list/list_"&theid&"_"&pageno-1&".htm title=""上页"">上页</a>"
else
lb=lb&"<a href='#'>上页</a>"
end if
ps=cint(pageno)-2???????????
? if ps<1 then???????????
? ps=1???????????
? end if
pe=clng(pageno)+5
if pe>mpage then pe=mpage
for i=ps to pe
if i=pageno then
lb=lb&"<strong>"&i&"</strong>"
else
lb=lb&"<a href=""/list/list_"&theid&"_"&i&".htm"">"&i&"</a>"
end if
next
?
if cint(pageno)<mpage and mpage>1 then
lb=lb&"<a href=/list/list_"&theid&"_"&pageno+1&".htm title=""下页"">下页</a>"
else
lb=lb&"<a href='#'>下页</a>"
end if
if cint(pageno)< mpage then
lb=lb&"<a href=/list/list_"&theid&"_"&mpage&".htm title=""末页"">末页</a>"
end if
以上就是爱站技术频道小编给大家介绍的ASP 数字分页效果代码,希望小编的内容对你有所帮助,如果需要了解更多信息,请关注js.aizhan.com吧!
原文链接:https://js.aizhan.com/develop/asp/11811.html
如有疑问请与原作者联系
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- asp中设置session过期时间方法总结 2020-03-30
- asp中日期时间函数介绍 2020-03-30
- asp教程中get post提交表单有5点区别 2020-03-30
- ASP 时间函数及如何获取服务器时间的写法 2020-03-30
- asp中的ckEditor的详细配置小结 2020-03-30
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash