asp分页生成html的程序脚本代码
2018-09-06 11:42
这是asp分页列表生成静态页面得asp小程序脚本
复制代码 代码如下:
<!--#includefile=conn.asp-->
<html><head><TITLE>分页测试</TITLE><LINKhref=inc/style.csstype=text/cssrel=stylesheet></head>
<%strHead=strHead&<html>
strHead=strHead&<head>
strHead=strHead&<TITLE>分页测试</TITLE>
strHead=strHead&<LINKhref=inc/style.csstype=text/cssrel=stylesheet>
strHead=strHead&</head>
%>
<%
sql=select*fromnews
setrs=server.createObject(ADODB.Recordset)
rs.opensql,conn,1,1
%><%
rs.pagesize=2
totalpage=rs.pagecount
rs.close
setrs=nothing
forj=1tototalpage
sql=select*fromnews
setrs=server.createObject(ADODB.Recordset)
rs.opensql,conn,1,1
whichpage=j
rs.pagesize=2
totalpage=rs.pagecount
rs.absolutepage=whichpage
howmanyrecs=0
%><%
str0=
str0=str0&</p>
str0=str0&<tablebgcolor=#cecfcealign=centerborder=0width=800cellpadding=2cellspacing=1>
%><%
dowhilenotrs.eofandhowmanyrecs<rs.pagesize
%><%
str0=str0&<trbgcolor=#f7f7f7>
str0=str0&<tdbgcolor=#f7f7f7align=center>&rs(0)&</td>
str0=str0&<tdbgcolor=#f7f7f7align=center>&rs(1)&</td>
str0=str0&<tdbgcolor=#f7f7f7align=center>&rs(2)&</td>
str0=str0&<tdbgcolor=#f7f7f7align=center>&rs(3)&</td>
str0=str0&</tr>
%><%
rs.movenext
howmanyrecs=howmanyrecs+1
loop
rs.close
setrs=nothing
%><%str0=str0&</table>
%><%
分页部分
ref=
ref=ref&<br>
ref=ref&<tablebgcolor=#cecfcealign=centerborder=0width=800cellpadding=0cellspacing=1>
ref=ref&<trbgcolor=#f7f7f7>
ref=ref&<td>
ref=ref&<b>Pages:&j&/&totalpage&</b>
ref=ref&</td>
ref=ref&<td>
ref=ref&<ahref=list_1.html&>&<FONTface=Webdings>9</FONT>&</a>
ifwhichpage=1then
ref=ref&<FONTface=Webdings>7</FONT>
else
ref=ref&<ahref=list_&j-1&.html&>&<FONTface=Webdings>7</FONT>&</a>
endif
forcounter=1tototalpage
ref=ref&<ahref=list_&counter&.html&>[&counter&]</a>
ref=ref&
ifcountermod10=0then
ref=ref&<br>
endif
next
if(whichpage>totalpageorwhichpage=totalpage)then
ref=ref&<FONTface=Webdings>8</FONT>
else
ref=ref&<ahref=list_&j+1&.html&>&<FONTface=Webdings>8</FONT>&</a>
endif
ref=ref&<ahref=list_&totalpage&.html&>&<FONTface=Webdings>:</FONT>&</a>
Dimfso,f
DimstrTitle,strContent,strOut
创建文件系统对象
Setfso=Server.createObject(Scripting.FileSystemObject)
Setf=fso.createTextFile(Server.MapPath(list_&j&.html),true)
写入网页内容
f.WriteLinestrHead&str0&ref
f.close
response.write正在生成第&j&个页面!<br>
%><%
next%>