|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
由于ASP还是一种Script语言所没除了大量使用组件外,没有办法提高其工作效率。它必须面对即时编绎的时间考验,同时我们还不知其背后的组件会是一个什么样的状况;分页 <%
'-------------------------------------------
' 接口:
' 属性:
' a、tip:项目提醒(如,“篇文章”);
' b、tablewidth:跳转页导航宽度
' 办法:
' a、SetRsObj()办法:设置ADODB.RECORDSET对象;
' b、ControlPages()办法:显示跳转页导航(“上一页”、“下一页”……)
' c、SetParams()办法:设置参数数组
' 典范:
' dim params(1,1)
' params(0,0) = "query" : params(0,1) = request("query")
' params(1,0) = "keyword" : params(1,1) = request("keyword")
' 该数组次要传递查询关头字(如字段关头字、工夫等),第一维是参数称号,第二维是参数值:以下http://…….asp?topage=2&query=yes&keyword=a
'
' set PageCtrl = new CPageCtrl
' PageCtrl.SetRsObj (RS) '设置ADODB.RECORDSET对象,个中RS是已创立好的ADODB.RECORDSET,即所要掌握的纪录集
' PageCtrl.tip = "篇文章"
' PageCtrl.tablewidth = "100%"
' PageCtrl.SetParams params
' PageCtrl.DimPage (15) '分页界说,每页15笔记录
' PageCtrl.ControlPages() '显示跳转页导航
'-------------------------------------------
class CPageCtrl
public tip, tablewidth
private setobjflag, rsobj, pages, record, setparamsflag, current, topage
dim params()
'----------------------------------
private sub class_initialize()
tablewidth = "100%"
end sub
'---------------------------------
public function SetRsObj(obj)
set rsobj = obj
setobjflage = true
end function
'----------------------------------
private function chksetobj()
if setobjflage <> true then response.End()
end function
'----------------------------------
public function DimPage(psize) '分页界说
dim topages
topage = request("topage")
if not rsobj.eof then
if not isempty(psize) then
rsobj.pagesize = cint(psize) '界说每页显示数量
else
rsobj.pagesize = rsobj.recordcount
end if
pages = rsobj.pagecount
record = rsobj.recordcount
if topage <> empty then
topages = CInt(topage)
if topage <= 1 then
rsobj.absolutepage = 1
elseif topages >= pages then
rsobj.absolutepage = pages
else
rsobj.absolutepage = topages
end if
end if
current = rsobj.absolutepage
end if
end function
'----------------------------------
public function SetParams(arrParams())
params = arrParams
setparamsflag = true
end function
'----------------------------------
public function controlpages()
dim url
url = "http://" & request.ServerVariables("HTTP_HOST") & request.ServerVariables("URL")
if setparamsflag = true then
row = ubound(params,1)
col = ubound(params,2)
if col <> 1 then
exit function
end if
for i = 0 to row
if params(i,0) <> empty then
condition = condition & "&" & params(i,0) & "=" & params(i,1)
'生成参数
end if
next
end if
response.write "<table width='" & tablewidth & "' border='0' cellspacing='0' cellpadding='0'>"
response.write "<form action='" & url & "' method='post'>"
response.write "<tr> "
response.write "<td height='20'> 今朝共有 <font color='red'><b>" & record & "</b></font> "& tip & " 以后分页情况 <font color='red'><b>" & current & "/" & pages & "</b></font></td>"
if current <> 1 then
response.write "<td width='40' align='center' height='20'>"
response.write "<a href='" & url & "?topage=1" & condition & "'>首 页</a>"
response.write "</td>"
response.write "<td width='44' align='center' height='20'>"
response.write "<a href='" & url & "?topage=" & current-1 & condition & "'>上一页</a>"
response.write "</td>"
else
response.write "<td width='40' align='center' height='20'>"
response.write "<font color='#999999'>首 页</font>"
response.write "</td>"
response.write "<td width='44' align='center' height='20'>"
response.write "<font color='#999999'>上一页</font>"
response.write "</td>"
end if
if current <> pages then
response.write </p> 减少客户内IT专业人才缺乏带来的影响。ASP的客户员工利用浏览器进入相关的应用软件,简单易用,无需专业技术支持。 |
|