马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
Windows本身的所有问题都会一成不变的也累加到了它的身上。安全性、稳定性、跨平台性都会因为与NT的捆绑而显现出来;vbscript|分页|函数感化:为了通用性思索,本函数次要功效为分页导航,界说数据库毗连和挪用数据在挪用页操纵.
1.1函数fPageCount内容
1.2包括文件abbr.asp,非必需
2.1利用函数例1
2.2利用函数例2
2.3利用函数例3
注:例中的剧本为跳转框必需
效果:
-------------------------------------------------------------
首页上十上一12345678910下一下十尾页转到:___
50篇/页1/21页1031篇
-------------------------------------------------------------
1.1函数fPageCount内容
<%ASPVBScript分页函数,byStabx,2006-04-22
挪用文件参数设置
RPP=50设置每页显现数量
I=1设置轮回入手下手数量
showNumberLink_=10数字导航显现数量
toPage_="?yearview="&request.QueryString("yearview")&"&pageview="页面链接
nonLinkColor_="#CCCCCC"非热链接色彩
数据库毗连
Setrs=Server.CreateObject("ADODB.Recordset")创建一个rs数据库查询
rs.ActiveConnection=MM_conn_STRING毗连字符串,这是Dreamweaver毗连字符串
rs.CursorType=1游标属性
rs.CursorLocation=2游标地位
rs.LockType=1界说数据库查询形式
rs.Open"selectarticle.*,class.*,nclass.*fromarticle,class,nclasswherearticle.classid=class.classidandarticle.nclassid=nclass.nclassidandyear(dateandtime)="&request.QueryString("yearview")&"orderbydateandtimedesc",MM_conn_STRING
挪用函数,显现散布导航栏
callfPageCount(RPP,rs,I,showNumberLink_,toPage_,nonLinkColor_)
挪用文件,显现数据操纵
ifrs.eoforrs.bofthen
else
fori=1torpp
response.Writers("title")&p_
rs.movenext
ifrs.eoforrs.bofthenexitfor
next
endif
FOR...NEXT语句段编纂显现内容,
functionfPageCount(RPP,rs,I,showNumberLink_,toPage_,nonLinkColor_)
toF_="首页"
toP10_="上十"
toP1_="上一"
toN1_="下一"
toN10_="下十"
toL_="尾页"
ifnotrs.eofornotrs.bofthen
pageview=CInt(Request("pageview"))读取URL页号
rs.PageSize=RPP界说每页显现纪录数
Ifpageview<=0Thenpageview=1假如pageview小于或即是0,前往值1
Ifpageview>rs.PageCountThenpageview=rs.PageCount假如pageview年夜于分页总数,前往分页末页值
rs.AbsolutePage=pageview界说以后页码
cPageNo=rs.AbsolutePage
tpagecount=rs.pagecount
response.Write"<formNAME=pageformID=pageform>"
IfcPageNo<1ThencPageNo=1假如页数小于1,默许为1;以后页,cPageNo=CurrentPageNO.
IftPageCount<1ThentPageCount=1
IfcPageNo>tPageCountThencPageNo=tPageCount
DimNaviLength
NaviLength=showNumberLink_显现数字链接数
DimStartPage,EndPage界说以后页,入手下手页,停止页
StartPage=(cPageNoNaviLength)*NaviLength+1为入手下手页赋值
ifpageview=1then判别是不是首页,假如是首页不增加链接,反之增加.
Response.Write"<fontcolor="&nonLinkColor_&">"&toF_&"</font>"
Else
Response.Write"<ahref="&toPage_&"1>"&toF_&"</a>"
EndIf
If(cPageNoModNaviLength)=0ThenStartPage=StartPage-NaviLength
EndPage=StartPage+NaviLength-1
IfEndPage>tPageCountThenEndPage=tPageCount
IfStartPage>1Then向后挪动一分页,十页为一分页,而且以1,11,21...为每页的入手下手篇数
Response.Write"<ahref="&toPage_&(cPageNo-(cPageNomod10)-NaviLength+1)&">"&toP10_&"</a>"
Else
Response.Write"<fontcolor="&nonLinkColor_&">"&toP10_&"</font>"
EndIf
Ifpageview1andpageview0Then后移一页
Response.Write"<ahref="&toPage_&(pageview-1)&">"&toP1_&"</a>"
Else
Response.Write"<fontcolor="&nonLinkColor_&">"&toP1_&"</font>"
EndIf
ForI=StartPageToEndPage
IfI=cPageNoThen
Response.Write"<b>"&I&"</b>"
Else
Response.Write"<ahref="&toPage_&I&">"&I&"</a>"
EndIf
IfItPageCountThenResponse.Write""
Next
Ifpageviewrs.PageCountandpageview0Then前移一页
Response.Write"<ahref="&toPage_&(pageview+1)&">"&toN1_&"</a>"
Else
Response.Write"<fontcolor="&nonLinkColor_&">"&toN1_&"</font>"
EndIf
IfEndPage<tpagecountThen向前挪动一分页,十页为一分页,而且以1,11,21为每页的入手下手篇数
Response.Write"<ahref="&toPage_&(cPageNo-(cPageNomod10)+NaviLength+1)&">"&toN10_&"</a>"
Else
Response.Write"<fontcolor=#CCCCCC>"&toN10_&"</font>"
EndIf
ifrs.PageCountpageviewthen判别是不是尾页
Response.Write"<ahref="&toPage_&rs.PageCount&">"&toL_&"</a>"
Else
Response.Write"<fontcolor="&nonLinkColor_&">"&toL_&"</font>"
EndIf
跳转框
response.Write"转到:<selectNAME=menu1onChange=MM_jumpMenu(parent,this,0)>"
fori=1totPageCount
response.Write"<optionvalue="&topage_&i
ifpageview=ithenresponse.Write"selected"
response.Write">第"&i&"页</option>"
next
response.Write"</select>"
页面信息
response.Writep_&sp2_&RPP&"篇/页"&sp2_&cPageNo&"/"&tPageCount&"页"&sp2_&rs.recordCount&"篇"
response.Write"</form>"
else
endif
endfunction
%>
1.2包括文件abbr.asp,非必需
<%
SiteInfomation
sitename_="绿色学院GreenInstitute"站点名字
homepageW_="首页"
siteurl_="http://127.0.0.1:83"站点域名
home_="<ahref="&siteurl_&">"&sitename_&"</a>"_fcksavedurl=""&siteurl_&">"&sitename_&"</a>""显现站名并加上首页链接
homepage_="<ahref="&siteurl_&">"&homepageW_&"</a>"显现"首页"并加站站点链接
sitepublic_="开站日期:2006-7-1"显现开站日期
siteadmin_="shawl.qiu"
siteadminW_="站长"
siteadminMail_="shawl.qiu@gmail.com"站长电子邮件
contactSiteAdmin_=siteadminW_&":<aHREF=mailto:"&siteadminMail_&">"&siteadmin_&"</a>"_fcksavedurl="mailto:"&siteadminMail_&">"&siteadmin_&"</a>""显现站长名字并加上电子邮件链接
NumberControl
n10_=10显现文章题目长度
n11_=11显现文章题目长度
n12_=12显现文章题目长度
n15_=15显现文章题目长度
HTMLTag
b_="<br/>"挪用换行符
p_="<p/>"
sp2_=""
sp2a_="->"
articleabout
author_="作者:"
hot_="抢手"
source_="来历:"
newPost_="<divclass=center>最新宣布</div>"
previousA_="上篇"
nextA_="下篇"
previous10_="上十"
next10_="下十"
previous1_="上一"
next1_="下一"
nullPA_="没有上篇"
nullNA_="没有下篇"
view_="检察:"
viewT_="次"
pagelinkW_="页面链接:"
Generalword
welcomeShort_="接待到临"
siteFoundtime_="开站日期:"
localsite_="本站"
pageindex.asp
pColumn_="父类"
sColumn_="子类"
pageclass.asp
c1_="class.asp?classid="class类一级链接
c2_="&nclassid="class类二级链接
pagearticle.asp
a1_="article.asp?classid="article页一级链接
a2_="&nclassid="article页二级链接
a3_="&articleid="article页三级链接
text_="注释:"
pagedateview.asp
ddv_="dateview.asp?dayview="
dyv_="dateview.asp?yearview="
dyvpv_="&pageview="
dmv_="dateview.asp?monthview="
dwkv_="dateview.asp?weekview="
dtv_="dateview.asp?todayview="
show_="显现"
today_="明天"
showAll_="一切文章"
showByW_="所属礼拜"
errorinfo
errorCidNidAid_="<metaHTTP-EQUIV=refreshCONTENT=3;URL=index.asp><metahttp-equiv=Content-Typecontent=text/html;charset=utf-8/><center>页面毛病,三秒后前往主页</center>"
errorNothing_="<center>没有内容</center>"
errorNJH_="<metaHTTP-EQUIV=refreshCONTENT=3;URL=index.asp><metahttp-equiv=Content-Typecontent=text/html;charset=utf-8/><center>没有内容,三秒后前往主页</center>"
querystring
rqsyv_=request.QueryString("yearview")
url
pagelink1_=siteurl_&request.ServerVariables("URL")&"?"&request.ServerVariables("QUERY_STRING")
pagelink_=pagelinkW_&"<ahref="&pagelink1_&">"&pagelink1_&"</a>"
%>
2.1利用函数例1
<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>
<%
RPP=50设置每页显现数量
I=1设置轮回入手下手数量
showNumberLink_=10
toPage_="?dayview="&request.QueryString("dayview")&"&pageview="
nonLinkColor_="#CCCCCC"
Setrs=Server.CreateObject("ADODB.Recordset")创建一个rs数据库查询
rs.ActiveConnection=MM_conn_STRING
rs.CursorType=1游标属性
rs.CursorLocation=2游标地位
rs.LockType=1界说数据库查询形式
rs.Open"selectarticle.*,class.*,nclass.*fromarticle,class,nclasswherearticle.classid=class.classidandarticle.nclassid=nclass.nclassidanddateandtime=#"&request.QueryString("dayview")&"#orderbyarticleiddesc",MM_conn_STRING
%>
<divCLASS="center"><%callfPageCount(RPP,rs,I,showNumberLink_,toPage_,nonLinkColor_)%></div>
<%
ifrs.eoforrs.bofthen
else
fori=1torpp%>
<divclass="floatRight80"><ahref="<%=ddv_&rs("dateandtime")%>"><%=rs("dateandtime")%></a></div><ahref="<%=c1_&rs("article.classid")%>"><%=rs("class")%></a>-><ahref="<%=c1_&rs("article.classid")&c2_&rs("article.nclassid")%>"><%=rs("nclass")%></a>-><ahref="<%=a1_&rs("article.classid")&a2_&rs("article.nclassid")&a3_&rs("articleid")%>"target="_blank"><%=rs("title")%></a><p/>
<%
rs.movenext
ifrs.eoforrs.bofthenexitfor
next
endif%>
<divCLASS="center"><%callfPageCount(RPP,rs,I,showNumberLink_,toPage_,nonLinkColor_)%></div>
<%rs.close
setrs=nothing%>
2.2利用函数例2
<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>
<%
RPP=50设置每页显现数量
I=1设置轮回入手下手数量
showNumberLink_=10
toPage_="?yearview="&request.QueryString("yearview")&"&pageview="
nonLinkColor_="#CCCCCC"
Dimrs界说链接名
Setrs=Server.CreateObject("ADODB.Recordset")创建一个rs数据库查询
rs.ActiveConnection=MM_conn_STRING
rs.CursorType=1游标属性
rs.CursorLocation=2游标地位
rs.LockType=1界说数据库查询形式
rs.Open"selectarticle.*,class.*,nclass.*fromarticle,class,nclasswherearticle.classid=class.classidandarticle.nclassid=nclass.nclassidandyear(dateandtime)="&request.QueryString("yearview")&"orderbydateandtimedesc",MM_conn_STRING
%>
<divCLASS="center"><%callfPageCount(RPP,rs,I,showNumberLink_,toPage_,nonLinkColor_)%></div>
<%
ifrs.eoforrs.bofthen
else
fori=1torpp%>
<divclass="floatRight80"><ahref="<%=ddv_&rs("dateandtime")%>"><%=rs("dateandtime")%></a></div><ahref="<%=c1_&rs("article.classid")%>"><%=rs("class")%></a>-><ahref="<%=c1_&rs("article.classid")&c2_&rs("article.nclassid")%>"><%=rs("nclass")%></a>-><ahref="<%=a1_&rs("article.classid")&a2_&rs("article.nclassid")&a3_&rs("articleid")%>"target="_blank"><%=rs("title")%></a><p/>
<%
rs.movenext
ifrs.eoforrs.bofthenexitfor
next
endif%>
<divCLASS="center"><%callfPageCount(RPP,rs,I,showNumberLink_,toPage_,nonLinkColor_)%></div>
<%rs.close
setrs=nothing%>
2.3利用函数例3
<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>
<%
RPP=50设置每页显现数量
I=1设置轮回入手下手数量
showNumberLink_=10
toPage_="?monthview="&request.QueryString("monthview")&"&pageview="
nonLinkColor_="#CCCCCC"
Setrs=Server.CreateObject("ADODB.Recordset")创建一个rs数据库查询
rs.ActiveConnection=MM_conn_STRING
rs.CursorType=1游标属性
rs.CursorLocation=2游标地位
rs.LockType=1界说数据库查询形式
rs.Open"selectarticle.*,class.*,nclass.*fromarticle,class,nclasswherearticle.classid=class.classidandarticle.nclassid=nclass.nclassidandyear(dateandtime)="&year(request.QueryString("monthview"))&"and"&"month(dateandtime)="&month(request.QueryString("monthview"))&"orderbydateandtimeasc",MM_conn_STRING
%>
<divCLASS="center"><%callfPageCount(RPP,rs,I,showNumberLink_,toPage_,nonLinkColor_)%></div>
<%
ifrs.eoforrs.bofthen
else
fori=1torpp%>
<divclass="floatRight80"><ahref="<%=ddv_&rs("dateandtime")%>"><%=rs("dateandtime")%></a></div><ahref="<%=c1_&rs("article.classid")%>"><%=rs("class")%></a>-><ahref="<%=c1_&rs("article.classid")&c2_&rs("article.nclassid")%>"><%=rs("nclass")%></a>-><ahref="<%=a1_&rs("article.classid")&a2_&rs("article.nclassid")&a3_&rs("articleid")%>"target="_blank"><%=rs("title")%></a><p/>
<%
rs.movenext
ifrs.eoforrs.bofthenexitfor
next
endif%>
<divCLASS="center"><%callfPageCount(RPP,rs,I,showNumberLink_,toPage_,nonLinkColor_)%></div>
<%rs.close
setrs=nothing%>
由于ASP提供的是一对多的服务,所以用户的一些特殊需求很难得到满足。 |