用ASP写的一个仿Google的翻页控制
来源:互联网 发布:excel剔除重复数据公式 编辑:程序博客网 时间:2024/05/01 20:27
最近在做一个全文检索时突发奇想,既然大家都习惯了用Google去搜东西,就干脆写一个类似Google的翻页吧,代码如下,使用时只需调用goGoogle()函数即可,样式在一个包含文件中懒的去找了,有兴趣的就自己写吧~~
google-style.asp:
<%
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Google-style Page Control
'@by Janylee at 2006.1.6
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function goGoogle(countRecord,thisPage,perItems,url)
'params:countRecord - total record count; thisPage - current page number; perItems - items count per page; url: turn to url address(include url params).
dim totalPageCount
totalPageCount = (countRecord / perItems) - cInt(countRecord mod perItems <> 0)
if totalPageCount > 0 then
dim arr,perPageHtml,nextPageHtml
arr = GetMinAndMaxPage(thisPage,totalPageCount)
if thisPage > 1 then
perPageHtml = "<a href="""& url & GetUrlSign(url) &"page="& thisPage-1 &""" class=""btnper"">上一页</a>"
else
perPageHtml = "<span class=""btnper"">上一页</span>"
end if
if thisPage < totalPageCount then
nextPageHtml = "<a href="""& url & GetUrlSign(url) &"page="& thisPage+1 &""" class=""btnnext"">下一页</a>"
else
nextPageHtml = "<span class=""btnnext"">下一页</span>"
end if
goGoogle = perPageHtml& makeControlItems(arr(0),arr(1),thisPage,url) &nextPageHtml
else
goGoogle = ""
end if
end function
function GetMinAndMaxPage(thisPage,totalPageCount)
dim arr(1)
if thisPage > 10 then
arr(0) = thisPage - 10
else
arr(0) = 1
end if
if thisPage + 9 < totalPageCount then
arr(1) = thisPage + 9
else
arr(1) = totalPageCount
end if
GetMinAndMaxPage = arr
end function
function GetUrlSign(url)
if inStr(url,"?") <> 0 then
GetUrlSign = "&"
else
GetUrlSign = "?"
end if
end function
function makeControlItems(dw,up,nw,url)
dim i,thisPageStyle,html
for i = dw to up
if i = nw then
thisPageStyle = " <span class=""seled"">"& i &"</span> "
else
thisPageStyle = " <a href="""& url & GetUrlSign(url) &"page="& i &""">"& i &"</a> "
end if
html = html& thisPageStyle
next
makeControlItems = html
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
%>
google-style.asp:
<%
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Google-style Page Control
'@by Janylee at 2006.1.6
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function goGoogle(countRecord,thisPage,perItems,url)
'params:countRecord - total record count; thisPage - current page number; perItems - items count per page; url: turn to url address(include url params).
dim totalPageCount
totalPageCount = (countRecord / perItems) - cInt(countRecord mod perItems <> 0)
if totalPageCount > 0 then
dim arr,perPageHtml,nextPageHtml
arr = GetMinAndMaxPage(thisPage,totalPageCount)
if thisPage > 1 then
perPageHtml = "<a href="""& url & GetUrlSign(url) &"page="& thisPage-1 &""" class=""btnper"">上一页</a>"
else
perPageHtml = "<span class=""btnper"">上一页</span>"
end if
if thisPage < totalPageCount then
nextPageHtml = "<a href="""& url & GetUrlSign(url) &"page="& thisPage+1 &""" class=""btnnext"">下一页</a>"
else
nextPageHtml = "<span class=""btnnext"">下一页</span>"
end if
goGoogle = perPageHtml& makeControlItems(arr(0),arr(1),thisPage,url) &nextPageHtml
else
goGoogle = ""
end if
end function
function GetMinAndMaxPage(thisPage,totalPageCount)
dim arr(1)
if thisPage > 10 then
arr(0) = thisPage - 10
else
arr(0) = 1
end if
if thisPage + 9 < totalPageCount then
arr(1) = thisPage + 9
else
arr(1) = totalPageCount
end if
GetMinAndMaxPage = arr
end function
function GetUrlSign(url)
if inStr(url,"?") <> 0 then
GetUrlSign = "&"
else
GetUrlSign = "?"
end if
end function
function makeControlItems(dw,up,nw,url)
dim i,thisPageStyle,html
for i = dw to up
if i = nw then
thisPageStyle = " <span class=""seled"">"& i &"</span> "
else
thisPageStyle = " <a href="""& url & GetUrlSign(url) &"page="& i &""">"& i &"</a> "
end if
html = html& thisPageStyle
next
makeControlItems = html
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
%>
- 用ASP写的一个仿Google的翻页控制
- 一个简单jsp的翻页控制
- 一个比较好的ASP翻页!
- 最近自己用asp+ajax写的仿clickeye效果
- 一个自认为貌似Baidu,Google的翻页导航控件
- 自己仿写一个ucosii(二) 任务控制块的简析
- 怎样写一个实现翻页的存储过程
- 写了一个android带动画翻页效果的程序
- 写一个仿string的类
- 仿写的一个HTTP小代码
- 用ASP写的一个转换程序
- 仿阿里巴巴同级产品翻页的实现
- 用ajax自己写仿 google search suggest的搜索提示
- asp.net 的分页翻页
- asp的翻页页码函数
- JQuery+JSON 实现的一个仿Google提示的代码
- 推荐google中国科学家写的一个系列
- 一个google高手写的心得体会
- 好文章,共享!
- VS打印思想
- 创建基于struts1.2 + Hibernate3.0 Web工程(第二部分)
- Windows XP/2000注册表速查手册(ie)
- Swing破局:打造半透明窗口
- 用ASP写的一个仿Google的翻页控制
- 窗
- 关于无线
- SQLServer和Oracle常用函数对比
- 钱的问题
- 在ASP.NET 2.0中实现数据的绑定
- 海豚式管理
- C#delegate的C++简易实现
- at指令