基于组件的asp编程之二--分页对象
// Design for Active Server Pages
//
// Copyright 2003 Version 1.0
// Made by newsunet
// 请不要删除这一段注释,自由传播,保留所有权
// ************************************************************************
/*//Ado.RecordSet记录分页对象
//设置分页
var RowCount =3
var fy=new JPageNavbar()
if (!rsRpt.Eof){
rs.PageSize = RowCount //设置数据集的页记录
fy.PageSize=RowCount
rs.AbsolutePage =fy.getCurrentPage()
fy.RecordCount=rs.RecordCount
fy.PageCount=rs.pageCount
fy.PnWidth="100%"
fy.PnAlign="right"
fy.PlWidth="100%" //表格宽度
fy.PlAlign="right" // 表格的对齐方式
}
//显示分页
<%fy.pnDisplay()%>
<%fy.plDisplay()%>
*/
function createJPageNavbar(){
//这个函数是vbscript的接口函数 ,vbscript不是基于对象的脚本语言
var objJPageNavbar=new JPageNavbar
return objJPageNavbar
}
function JPageNavbar(){
// public members
this.PageSize="0"
this.RecordCount="0" //总记录数
this.PageCount="1" //总页数
this.CurrentPage="1"
this.PnWidth="100%"
this.PnAlign="right"
this.PlWidth="100%" //表格宽度
this.PlAlign="right" // 表格的对齐方式
// private members
//public methods
this.getCurrentPage=_getCurrentPage
this.pnDisplay = _PN_show;
this.plDisplay = _PL_show;
//private methods
}
function _getCurrentPage(){
//当前显示的是第几页
//取得当前页
var pageNo = Request.QueryString ("PageNo")
//如果没有选择第几页,则默认显示第一页;
if (isNaN(pageNo)) {
pageNo = 1
}
this.CurrentPage=pageNo
return pageNo
}
function _PL_show(){
var strBuilder=new String()
strBuilder=""
var p=(this.CurrentPage-(this.CurrentPage%10))/10 //计算分页显示的页数
//首组为第0族
strBuilder+="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" "
strBuilder+=" width=\""+this.PlWidth+"\" align=\""+this.PlAlign+"\">"
strBuilder+=" <tr> "
strBuilder+=" <td valign=\"middle\" align=\"right\">分页:"
if (this.CurrentPage==1){
strBuilder+="<font face=\"webdings\" color=\"#ff0000\">9</font> "
}
else{
strBuilder+="<a href=\"?PageNo=1\" title=\"首页\"><font face=\"webdings\">9</font></a> "
}
//上十页
if (p*10>0){
strBuilder+="<a href=\"?PageNo="+(p*10)+"\" title=上十页><font
face=\"webdings\">7</font></a> "
}
strBuilder+="<b>"
//分页列表
for(var i=p*10+1;i<=p*10+10;i++){
if (i==this.CurrentPage){
strBuilder+="<font color=\"#000000\">"+i+"</font> "
}
else{
strBuilder+="<a href=?PageNo="+i+" title=\"转到: 第"+i+"页\">"+i+"</a> "
}
if (i>=this.PageCount) break;
}
strBuilder+= "</b>"
//显示下十页
if (i<this.PageCount){
strBuilder+="<a href=\"?PageNo="+i+"\" title=\"下十页\"><font
face=\"webdings\">8</font></a> "
}
//显示尾页
if (this.CurrentPage==this.PageCount){
strBuilder+= "<font
【相关文章:】
没有相关文章
【发表评论】【打印此文】【关闭窗口】【点击数: 】
