ASP分页列表生成静态页面的小程序脚本

程序|分页|脚本|静态|页面

<!--#include file="conn.asp"-->
<html><head><TITLE>分页测试</TITLE><LINK href="inc/style.css" type=text/css rel=stylesheet></head>
<%strHead=strHead&"<html>"
strHead=strHead&"<head>"
strHead=strHead&"<TITLE>分页测试</TITLE>"
strHead=strHead&"<LINK href=""inc/style.css"" type=text/css rel=stylesheet>"
strHead=strHead&"</head>"
%>
<%
sql="select * from news"
set rs=server.createObject("ADODB.Recordset")
rs.open sql,conn,1,1
%><%
rs.pagesize=2
totalpage=rs.pagecount
rs.close
set rs=nothing

for j=1 to totalpage
sql="select * from news"
set rs=server.createObject("ADODB.Recordset")
rs.open sql,conn,1,1

whichpage=j
rs.pagesize=2
totalpage=rs.pagecount
rs.absolutepage=whichpage
howmanyrecs=0
%><%
str0=""
str0=str0&"</p>"
str0=str0&"<table bgcolor=#cecfce align=center border=0 width=800 cellpadding=2 cellspacing=1>"
%><%
do while not rs.eof and howmanyrecs<rs.pagesize
%><%
str0=str0&"<tr bgcolor=#f7f7f7>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(0)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(1)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(2)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(3)&"</td>"
str0=str0&"</tr>"
%><%
rs.movenext
howmanyrecs=howmanyrecs+1
loop
rs.close
set rs=nothing
%><%str0=str0&"</table>"
%><%

'分页部分
ref=""

ref=ref&"<br>"
ref=ref&"<table bgcolor=#cecfce align=center border=0 width=800 cellpadding=0 cellspacing=1> "
ref=ref&"<tr bgcolor=#f7f7f7>"
ref=ref&"<td> "
ref=ref&"<b>Pages: " & j & " / " & totalpage &"</b>"
ref=ref&"</td>"
ref=ref&"<td> "

ref=ref&"<a href=list_1.html"&">" & "<FONT face=Webdings>9</FONT>" & "</a> "
if whichpage=1 then
ref=ref&"<FONT face=Webdings>7</FONT>"
else
ref=ref&"<a href=list_"&j-1&".html"&">" & "<FONT face=Webdings>7</FONT>" & "</a> "
end if

for counter=1 to totalpage
ref=ref&"<a href=list_"&counter&".html"&">[" & counter & "]</a>"
ref=ref& " "
if counter mod 10 = 0 then
ref=ref& "<br>"
end if
next

if (whichpage>totalpage or whichpage=totalpage) then
ref=ref&"<FONT face=Webdings>8</FONT>"
else
ref=ref&"<a href=list_"&j+1&".html"&">" & "<FONT face=Webdings>8</FONT>" & "</a> "
end if
ref=ref&"<a href=list_"&totalpage&".html"&">" & "<FONT face=Webdings>:</FONT>" & "</a> "

Dim fso,f
Dim strTitle,strContent,strOut
'创建文件系统对象
Set fso=Server.createObject("Scripting.FileSystemObject")
Set f=fso.createTextFile(Server.MapPath("list_"&j&".html"),true)

'写入网页内容
f.WriteLine strHead&str0&ref
f.close
response.write "正在生成第"&j&"个页面!<br>"
%><%
next%>

时间: 2024-08-01 18:39:28

ASP分页列表生成静态页面的小程序脚本的相关文章

ASP.NET动态生成静态页面的实例代码

生成静态页有很多好处,可以缓解服务器压力.方便搜索网站搜索等等,下面介绍一下生成静态页的实例代码,有需要的朋友可以参考一下   最近突然想把项目中新闻管理模块做成静态页,在网上找到很多很好的文章,在这里记录一下,现在只是实现静态页面的生成并没有实现分页功能.其主要原理就是读取数据库的数据然后替换掉静态模板页的内容. 首先制作一个模板页,暂时命名为template.htm,示例代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transit

ASP.NET动态生成静态页面的实例代码_实用技巧

最近突然想把项目中新闻管理模块做成静态页,在网上找到很多很好的文章,在这里记录一下,现在只是实现静态页面的生成并没有实现分页功能.其主要原理就是读取数据库的数据然后替换掉静态模板页的内容.首先制作一个模板页,暂时命名为template.htm,示例代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-trans

ASP.NET,生成静态页面时,代码HttpContext.Current.Server.Execute()出现错误

问题描述 各位大神好,项目里生成HTML静态页面,执行到HtmlProxy类时,出现异常错误HttpContext.Current.Server.Execute("article_detailed.aspx?nid="+id,sw);麻烦各位大神赐教 解决方案 解决方案二:提示已经说了.你的IIS配置的asp.net模式有错误,它不支持asp.net的这个操作.解决方案三:引用1楼sp1234的回复: 提示已经说了.你的IIS配置的asp.net模式有错误,它不支持asp.net的这个

ASP.NET C# 生成静态页面简单方法

//源码是替换掉模板中的特征字符             string mbPath = Server.MapPath("template.html");            Encoding code = Encoding.GetEncoding("gb2312");            StreamReader sr = null;            StreamWriter sw = null;            string str = null

ASP新闻分页,将一篇过长的文章分页,生成静态页面_应用技巧

上次还是CSDN里的朋友回答的,我复制了下来.原文如下 =========================== 利用统计文章字数,然后达到一定字数就截断输出,但是分页的内容就会在莫名其妙的地方截断,不是很友好. 很简单,在要截断的地方附近找下面的符号: :'"?.!;'".! 如果后面存在<p>或<br>就分页.主要是要研究文章的格式. <% if Request.ServerVariables("Content_Length") &g

Asp.net生成静态页面并分页

asp教程.net生成静态页面并分页 <!doctype html public "-//w3c//dtd html 4.01 transitional//en""http://www.w3.org/tr/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>     <meta http-equiv="conte

超简单asp生成静态页面代码

<form method="post" action=""> <textarea name="asp2html" style="display:none"><!--#include file="htmer.asp"--></textarea> <input type="submit" value="生成html页"

asp.net生成静态页面代码

asp教程.net生成静态页面代码 private static void createfile(string userid, string filename, string htmlcode)         {             filename += ".html";             string localpath = "e:/www.111cn.net/sun/sundecorativesystem/users/" + userid;    

asp.net生成静态页面方法详细说明

最常用的方法从文件读取模版,替换模版中的参数后输出文件,这种方法的生成速度上比第一种要快许多,而且模版内容可以用工具任意编辑 主要代码: using system; using system.collections; using system.componentmodel; using system.data; using system.drawing; using system.web; using system.web.sessionstate; using system.web.ui; u