在ASP中,用JScript脚本实现分页的另类办法
2004-10-27 10:28:14 来源:WEB开发网<%@LANGUAGE="javaSCRipT" CODEPAGE="936"%>
<!--#include file="connect.asp"-->
<!--#include file="news.asp"-->
<%
var DataSet,sql,DataList;
var i=0;
var j=0;
DataList=new News();
DataSet=Server.CreateObject("Adodb.recordset");
sql="select * from News where ngroup='集团新闻' order by id desc";
DataSet.Open(sql,DataConn,1,1);
//是否有数据
if ((DataSet.eof)&&(DataSet.bof))
{
Response.Write("<BR>" );
Response.Write("=== 暂无 ===");
Response.Write("<BR><BR>");
Response.End();
}
//记录总数
NumRecords=DataSet.RecordCount;
//设定每页最大记录数
PageSize=3;
//总页数
NumPages=Math.ceil(NumRecords/PageSize);
//当前页
i=Request.QueryString("CurrentPageID").Count;
if (i==0)
{
CurrentPageID=1;
}
else
{
CurrentPageID=parseInt(Request.QueryString("CurrentPageID"));
}
//初始化
PReviousPageID=CurrentPageID-1;
NextPageID=CurrentPageID+1;
HomePage=1;
EndPage=NumPages;
//内容列表
DataSet.MoveFirst;
DataSet.Move((CurrentPageID-1)*PageSize,1);
while (!DataSet.eof && j<PageSize)
{
Response.Write("<a href=show.asp?id="+DataSet("id")+" target=\"_blank\">"+DataSet("subject")+"</a><br>");
j=j+1;
DataSet.MoveNext;
}
//设定URL
if (CurrentPageID == HomePage)
{
Response.Write("<p class='Normal'><a href=list.asp?CurrentPageID="+HomePage+">首页</a> ");
Response.Write("上一页 ");
Response.Write("<a href=list.asp?CurrentPageID="+NextPageID+">下一页</a> ");
Response.Write("<a href=list.asp?CurrentPageID="+EndPage+">尾页</a> </p>");
}
else if (CurrentPageID == EndPage)
{
Response.Write("<p class='Normal'><a href=list.asp?CurrentPageID="+HomePage+">首页</a> ");
Response.Write("<a href=list.asp?CurrentPageID="+PreviousPageID+">上一页</a> ");
Response.Write("下一页 ");
Response.Write("<a href=list.asp?CurrentPageID="+EndPage+">尾页</a> </p>");
}
else
{
Response.Write("<p class='Normal'><a href=list.asp?CurrentPageID="+HomePage+">首页</a> ");
Response.Write("<a href=list.asp?CurrentPageID="+PreviousPageID+">上一页</a> ");
Response.Write("<a href=list.asp?CurrentPageID="+NextPageID+">下一页</a> ");
Response.Write("<a href=list.asp?CurrentPageID="+EndPage+">尾页</a> </p>");
}
%>
- ››asp.net页面弄成伪静态页面
- ››Asp.net 中将汉字转换成拼音的方法
- ››ASP.NET及JS中的cookie基本用法
- ››ASP.NET获取MS SQL Server安装实例
- ››asp.net实现调用百度pai 在线翻译英文转中文
- ››ASP.NET页面选项进行提示判断
- ››Asp.net定时执行程序
- ››ASP.NET中利用DataList实现图片无缝滚动
- ››ASP.NET验证控件RequiredFieldValidator
- ››ASP.NET中使用System.Net.Mail发邮件
- ››ASP.NET中获取用户控件中控件的ID
- ››ASP.NET中FileBytes写成文件并存档
更多精彩
赞助商链接