asp数字分页函数 实际使用例子。
2011-04-14 18:41
197 查看
//调用例子。上面的函数我是封装在pagefunction.asp文件里面的 注明:在引入pagefunction.asp文件之前的也是可以封装成一个固定的文件里面。然后通过引入,调用对应的函数的。
//函数是代码重用的最基础的封装。练习多了,代码敲多了,很多基本的功能,都可以逐步封装成为自己的库代码
<%
Const MaxPerPage=1
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(SafeRequest("page",1)) then
currentPage=Cint(SafeRequest("page",1))
else
currentPage=1
end if
i=0
rs.open "select * from acticle where categoryid=391 order by adddate desc",conn,1,1
if rs.eof and rs.bof then
rs.close
response.write "<center>目前还没有新闻!</center>"
else
totalPut=rs.recordcount
TotalPages=totalPut/MaxPerPage
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut / MaxPerPage
else
currentpage= totalPut / MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"newslist.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"newslist.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"newslist.asp"
end if
end if
end if
sub showContent
%>
<ul>
<%
do while not rs.eof
i=i+1
%>
<li><a href="news.asp?id=<% = rs("id") %>"><%=left(rs("name"),50)%></a><span><% = Year(rs("adddate")) %>.<% = Month(rs("adddate")) %>.<% = day(rs("adddate")) %></span><div class="clear"></div></li>
<%
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
%>
</ul>
<%
end sub
%>
<!--#include file="pagesfunction.asp"-->
//函数是代码重用的最基础的封装。练习多了,代码敲多了,很多基本的功能,都可以逐步封装成为自己的库代码
<%
Const MaxPerPage=1
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(SafeRequest("page",1)) then
currentPage=Cint(SafeRequest("page",1))
else
currentPage=1
end if
i=0
rs.open "select * from acticle where categoryid=391 order by adddate desc",conn,1,1
if rs.eof and rs.bof then
rs.close
response.write "<center>目前还没有新闻!</center>"
else
totalPut=rs.recordcount
TotalPages=totalPut/MaxPerPage
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut / MaxPerPage
else
currentpage= totalPut / MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"newslist.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"newslist.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"newslist.asp"
end if
end if
end if
sub showContent
%>
<ul>
<%
do while not rs.eof
i=i+1
%>
<li><a href="news.asp?id=<% = rs("id") %>"><%=left(rs("name"),50)%></a><span><% = Year(rs("adddate")) %>.<% = Month(rs("adddate")) %>.<% = day(rs("adddate")) %></span><div class="clear"></div></li>
<%
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
%>
</ul>
<%
end sub
%>
<!--#include file="pagesfunction.asp"-->
相关文章推荐
- asp.net中Datalist使用数字分页的实现方法
- asp.net中Datalist使用数字分页的实现方法
- asp.net Repeater使用例子,包括分页
- asp 分页 函数 及调用 例子
- asp.net中Datalist使用数字分页的实现方法
- AspNetPager的使用,分页显示
- ASP.NET 大量数据查询分页例子
- asp.net中日立函数Calendar的使用方法
- ASP生成大小写字母与数字混合随机数的函数
- Asp.Net[C#] 使用GridView 分页,编辑,删除,导出XML完整页面
- jQuery标签替换函数replaceWith()的使用例子
- mysql+java实现分页显示的例子使用limit
- 【ASP.NET】 中 system.math 函数使用
- ASP.NET使用EasyUI-DataGrid + ashx + JQuery Ajax:实现数据的增删查改,查询和分页!
- 使用NHibernate+.net Ajax +AspNetPage进行分页
- jquery live 函数使用的一个例子,和一些帮助文档
- asp.net中使用分页控件,并绑定数据到GridView或Repeater
- 一个实用的ASP分页函数
- 使用VB开发封装ASP的DLL例子
- ASP.Net 2.0中使用新的WebForm_DoPostBackWithOptions函数取代常规以前所使用的__doPostback函数