|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
缺乏可以共同遵循的行业标准,ASP还处在发展初期,大家对它的理解不同,如产品和服务标准,收费标准等,不利于行业的健康发展。分页|技能效果
首页上十上一12345678910下一下十尾页转到___
页数:1/25页篇数:125
主文件nclass.asp
包括文件top.asp||bottom.asp||abbrword.asp||conn.asp
内容
---/-----------------------------------------------------------
nclass.asp
<%@LANGUAGE="VBSCRIPT"CODEPAGE="65001"%>
<!--#includefile="Connections/conn.asp"-->
<%
subject:ASP分页技能
author:Stabx<shawl.qiu@gmail.com>
blog:http://btbtd.exblog.jp//http://my.opera.com/btbtd/
blogname:Phoenix.GI-P.GI
date:2006-4-19
rsn.PageCount/总页数
pageview/以后页数
DimI界说轮回变量
DimRPPRPP:指定每页显现的纪录数,
Dimpageview翻页变量
I=1从1入手下手
RPP=50每页显现50笔记录
pageview=CInt(Request("pageview"))读取URL页号
Dimrsn界说链接名
Setrsn=Server.CreateObject("ADODB.Recordset")创建一个rsn数据库查询
rsn.ActiveConnection=MM_conn_STRING这是DW的链接字符串
rsn链接体例
rsn.Source="SELECT*FROMarticleWHEREclassid="&request.QueryString("classid")&"andnclassid="&request.QueryString("nclassid")&"ORDERBYarticleidDESC"
rsn查询语句,SELECT一切列FROM表WHERE前提ORDERBY前提
rsn.CursorType=1游标属性
rsn.CursorLocation=2游标地位
rsn.LockType=1
界说数据库查询形式
rsn.Open()
翻开数据库链接
ifnotrsn.eofthen显现不为空的数据
endif
rsn.PageSize=RPP
界说每页显现纪录数
Ifpageview<=0Thenpageview=1假如pageview小于或即是0,前往值1
Ifpageview>rsn.PageCountThenpageview=rsn.PageCount假如pageview年夜于分页总数,前往分页末页值
rsn.AbsolutePage=pageview界说以后页码
SubShowPageInfo(tPageCount,cPageNo)界说子例程ShowPageInfo,显现页数和总页
Response.WritecPageNo&"/"&tPageCount&"页"显现以后页和总页数
EndSub
SubShowPageNavi(tPageCount,cPageNo)
界说子例程ShowPageNavi,显现分页号
IfcPageNo<1ThencPageNo=1
假如页数小于1,默许为1
IftPageCount<1ThentPageCount=1
IfcPageNo>tPageCountThencPageNo=tPageCount
DimNaviLength
NaviLength=10显现数字链接个数
DimI,StartPage,EndPage界说以后页,入手下手页,停止页
StartPage=(cPageNoNaviLength)*NaviLength+1为入手下手页赋值
ifpageview=1then判别是不是首页,假如是首页不增加链接,反之增加.
Response.Write"<fontcolor=""#CCCCCC"">首页</font>"显现没有增加链接热门的"首页"
Else
Response.Write"<ahref="&nc1_&rqsc_&nc2_&rqsnc_&nc3_&"1>首页</a>"首页链接
EndIf
If(cPageNoModNaviLength)=0ThenStartPage=StartPage-NaviLength
EndPage=StartPage+NaviLength-1
IfEndPage>tPageCountThenEndPage=tPageCount
IfStartPage>1Then向后挪动一分页,十页为一分页
Response.Write"<ahref="&nc1_&rqsc_&nc2_&rqsnc_&nc3_&(cPageNo-NaviLength)&">"&previous10_&"</a>"
Else
Response.Write"<fontcolor=""#CCCCCC"">"&previous10_&"</font>"
EndIf
Ifpageview1andpageview0Then后移一页
Response.Write"<ahref="&nc1_&rqsc_&nc2_&rqsnc_&nc3_&(pageview-1)&">"&previous1_&"</a>"
Else
Response.Write"<fontcolor=""#CCCCCC"">"&previous1_&"</font>"
EndIf
ForI=StartPageToEndPage
IfI=cPageNoThen
Response.Write"<b>"&I&"</b>"
Else
Response.Write"<ahref="&nc1_&rqsc_&nc2_&rqsnc_&nc3_&I&">"&I&"</a>"
EndIf
IfItPageCountThenResponse.Write""
Next
Ifpageviewrsn.PageCountandpageview0Then前移一页
Response.Write"<ahref="&nc1_&rqsc_&nc2_&rqsnc_&nc3_&(pageview+1)&">"&next1_&"</a>"
Else
Response.Write"<fontcolor=""#CCCCCC"">"&next1_&"</font>"
EndIf
IfEndPage<tPageCountThen向后挪动一分页,十页为一分页
Response.Write"<ahref="&nc1_&rqsc_&nc2_&rqsnc_&nc3_&(cPageNo+NaviLength)&">"&next10_&"</a>"
Else
Response.Write"<fontcolor=#CCCCCC>"&next10_&"</font>"
EndIf
ifrsn.PageCountpageviewthen判别是不是尾页
Response.Write"<ahref="&nc1_&rqsc_&nc2_&rqsnc_&nc3_&rsn.PageCount&">尾页</a>"
Else
Response.Write"<fontcolor=""#CCCCCC"">尾页</font>"
EndIf
EndSub
%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>UntitledDocument</title>
</head>
<body>
<!--#includevirtual="top.asp"-->
<divclass="c"</div>
<scriptlanguage="JavaScript"type="text/JavaScript">
<!--
functionMM_jumpMenu(targ,selObj,restore){//v3.0
eval(targ+".location="+selObj.options[selObj.selectedIndex].value+"");
if(restore)selObj.selectedIndex=0;
}
//-->
</script>
<divCLASS="center">
<formNAME="pageform"ID="pageform">
<%showPageNavirsn.PageCount,pageview%>
<selectNAME="menu1">
<%fori=1torsn.PageCount%>
<optionVALUE="<%="nclass.asp?classid="&rqsc_&"&nclassid="&rqsnc_&"&pageview="&i%>"
<%ifpageview=ithen%>selected<%endif%>>
第<%=i%>页
</option>
<%next%>
</select>
</form>
</div>
<%
Ifrsn.EOFORrsn.BOFThen
Else
ForI=1ToRPP
%>
<!--<%=(pageview-1)*RPP+I%>-->
<p/>
<%=rsn("dateandtime")%><ahref="<%=t1_&rsn("classid")&t2_&rsn("nclassid")&t3_&rsn("articleid")%>"><%=rsn("title")%></a>
<%
rsn.MoveNext
Ifrsn.EOFORrsn.BOFThenExitFor
Next
EndIf
%>
<divCLASS="center">
<formNAME="pageform"ID="pageform">
<%showPageInforsn.PageCount,pageview%>
<%showPageNavirsn.PageCount,pageview%>
<selectNAME="menu1">
<%fori=1torsn.PageCount%>
<optionVALUE="<%="nclass.asp?classid="&rqsc_&"&nclassid="&rqsnc_&"&pageview="&i%>"
<%ifpageview=ithen%>selected<%endif%>>
第<%=i%>页
</option>
<%next%>
</select>
</form>
<%=pageNum_%>:<%showPageInforsn.PageCount,pageview%>
<%=articleNum_%>:<%Response.Write(rsn.RecordCount)%><br/>
</div>
<!--#includevirtual="bottom.asp"-->
</body>
</html>
---/-----------------------------------------------------------
top.asp
<linkHREF="CSS.css"REL="stylesheet"TYPE="text/css">
<!--#includevirtual="include/abbrword.asp"-->
<!--#includevirtual="include/columnclass.asp"-->
<%
sethomelink
DimsiteinfoHomelink
DimsiteinfoHomelink_numRows
SetsiteinfoHomelink=Server.CreateObject("ADODB.Recordset")
siteinfoHomelink.ActiveConnection=MM_conn_STRING
siteinfoHomelink.Source="SELECT*FROMsiteinfo"
siteinfoHomelink.CursorType=0
siteinfoHomelink.CursorLocation=1
siteinfoHomelink.LockType=1
siteinfoHomelink.Open()
siteinfoHomelink_numRows=0
homeurl=siteinfoHomelink.Fields.Item("siteurl").Value
sitename=siteinfoHomelink.Fields.Item("sitename").Value
home="<ahref="&(siteinfoHomelink.Fields.Item("siteurl").Value)&">"&(siteinfoHomelink.Fields.Item("sitename").Value)&"</a>"
pageurl=homeurl&request.ServerVariables("URL")&"?"&request.ServerVariables("QUERY_STRING")
pagelink="<ahref="&pgeurl&">"&pageurl&"</a>"
%>
---/-----------------------------------------------------------
bottom.asp
<%
DimrsSiteinfo
DimrsSiteinfo_numRows
SetrsSiteinfo=Server.CreateObject("ADODB.Recordset")
rsSiteinfo.ActiveConnection=MM_conn_STRING
rsSiteinfo.Source="SELECT*FROMsiteinfo"
rsSiteinfo.CursorType=0
rsSiteinfo.CursorLocation=1
rsSiteinfo.LockType=1
rsSiteinfo.Open()
rsSiteinfo_numRows=0
%>
<divclass="center"><%=(rsSiteinfo.Fields.Item("project").Value)%>|<%=(rsSiteinfo.Fields.Item("sitecopyright").Value)%><ahref="<%=(rsSiteinfo.Fields.Item("siteurl").Value)%>"><%=(rsSiteinfo.Fields.Item("sitename").Value)%></a></div><br/>
<divclass="center"><%=siteFoundtime_%><%=(rsSiteinfo.Fields.Item("sitefoundtime").Value)%><%=siteAdmin_%><ahref="">mailto:<%=(rsSiteinfo.Fields.Item("siteadminemail").Value)%>"><%=(rsSiteinfo.Fields.Item("siteadmin").Value)%></div>
<%
rsSiteinfo.Close()
SetrsSiteinfo=Nothing
%>
---/-----------------------------------------------------------
abbrword.asp
<%
SiteInfomation
siteName_="绿色学院GreenInstitute"
siteUrl_="http://gi.2288.org:88/"
Generalword
welcomeShort_="接待到临"
siteAdmin_="站长:"
siteFoundtime_="开站日期:"
homeurl_="首页"
error
error_="<center>页面ID堕落,或文章已删除</center>"
errorA_="<center>文章ID堕落</center>"
errorN_="没有该篇"
nothing_="没有了"
nodata_="<center>没无数据</center>"
pageword
previous1_="上一"
next1_="下一"
previous_="上页"
next_="下页"
previousP_="上页"
nextP_="下页"
previous10_="上十"
next10_="下十"
previousA_="上篇"
nextA_="下篇"
previousD_="上一天"
nextD_="下一天"
previousY_="上年"
nextY_="下年"
previousW_="上礼拜"
nextW_="下礼拜"
today_="明天"
ArticlesColumn
columnClass_="主类:"
columnNclass_="子类:"
descriptworl
title_="题目"
article_="文章"
Categoryworld
hotHits_="抢手文章"
coldHits_="冷门文章"
newA_="比来更新"
show_="显现"
showAll_="一切文章"
pagearticles.asp
text_="注释"
hitsUp1_="点击:"
source_="来历:"
author_="作者:"
postDate_="宣布日期:"
sourceColumn_="所属栏目:"
pagelink_="页面链接:"
text_="注释:"
fashion_="抢手"
pagenclass.asp
nc1_="nclass.asp?classid="
nc2_="&nclassid="
nc3_="&pageview="
pageNum_="页数"
articleNum_="篇数"
pagedateview.asp
dat1="dateview/dateview.asp?dayview="
dat2="dateview.asp?dayview="
dv_=request.QueryString("dayview")
dvP1_=year(dv_)&"-"&month(dv_)&"-"&day(dv_)+1
dvM1_=year(dv_)&"-"&month(dv_)&"-"&day(dv_)-1
pageyearview.asp
yvE_="<center>没有该年份的数据</center>"
pagemonthview.asp
previousM_="上月"
nextM_="下月"
pageweekview.asp
weekA_="所属礼拜"
week_="礼拜"
pagetodayview.asp
tvv_="todayview.asp"
URLabbr.
up1_="../"
rqsc_=request.QueryString("classid")
rqsnc_=request.QueryString("nclassid")
rqs_=request.QueryString("articleid")
rqsdv_=request.QueryString("dayview")
articleid_="articles.asp?articleid="
articleid1_="articles1.asp?articleid="
t_="t.asp?nclassid="&nclassidSSS&"&articleid="&articleid
t1_="t.asp?classid="
t2_="&nclassid="
t3_="&articleid="
dvv_="dateview.asp?dayview="
yvv_="yearview.asp?yearview="
mvv_="monthview.asp?monthview="
wvv_="weekview.asp?weekview="
classid_="class.asp?classid="
nclassid_="nclass.asp?nclassid="
abbrid_="articles.asp?classid="&classid&"&nclassid="&nclassid&"&articleid="
abbrid1_="t.asp?classid="&classid&"&nclassid="&nclassid&"&articleid="
%>
---/-----------------------------------------------------------
conn.asp
<%
FileName="Connection_ado_conn_string.htm"
Type="ADO"
DesigntimeType="ADO"
HTTP="true"
Catalog=""
Schema=""
DimMM_conn_STRING
MM_conn_STRING="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath("/data/data.mdb")
%>
---/-----------------------------------------------------------
无法实现跨操作系统的应用。当然这也是微软的理由之一,只有这样才能发挥ASP最佳的能力。可是我却认为正是Windows限制了ASP,ASP的概念本就是为一个能让系统运行于一个大的多样化环境而设计的; |
|