asp+|fso| page |fso| pagination or the first time in csdn to write articles, I am literary and theoretical knowledge is limited, write incorrect place welcome correction. In fact, there are already many ASP generated HTM articles on the Internet
, there is a way to generate asp+xml, although there is a good thing is not to write the template program can directly refer to the original page to generate the source code to use, but
When I tested this method, I found that it had poor stability and high speed requirements (not on the server, of course). Especially in the virtual space often error, it is possible in this
People in this method code to deal with the reasons for the lack of it. Long story short, this article uses another common method of ASP+FSO, and the framework is also applied to
When processing a large number of paging to reduce the build time used, this method is for some large pages of ASP files.
Here I quote a simple example: (Tourism e-commerce) hotels in major cities in the country apply static page (HTM) paging display
1. Application System Environment: Win2000+asp+mssql/access (the database is basically not related to the general) +iis5.0
2.1 Cities List (cityhtml): includes the definition of static HTM name a total of three fields (city ID (AutoNumber), city name (CityName such as Beijing), generate HTM prefix name (htmlstartname such as Beijing))
3.1 National hotels: Here I only set up three fields (hotel ID (AutoNumber), City name (town), hotel name (hotelname)) convenient to reference examples.
4.1 ASP pages (tohtm.asp) (generated HTM used)
5.1 Cycle frames page (iframetohtm.asp), application framework batch generation HTM
The following gives the source of two pages
Looping frames for batch-generated pages: iframetohtm.asp
<!--#include file= "conn.asp"--> "Connection database
<%
Dim rs,sql,j
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT * from cityhtml" ' opens the National City list
Rs.Open sql,conn,1,1
Do until rs.eof ' cycle of major cities%>
<!--The following application framework opens the Tohtml build page-->
<iframe name= "loadrchtm<%=j%>" frameborder=0 width=100% height=30 scrolling=no src= "ToHtml.asp"? City=<%=cstr (RS ("City"))%>&htmlstartname=<%=rs ("Htmlstart")%> "></IFrame>
<%rs.movenext
Loop%>
Build Program page: tohtm.asp I write a comment on the source code * *
<!--#include file= "conn.asp"--> data Connection File
<%
On error Resume Next ' fault-tolerant processing
Dim City ' defines the cities that get the page to be generated
City=request.querystring ("city") ' Get the resulting cities hotel value from the frame it will be introduced in the following
Htmlstartname=request.querystring ("Htmlstartname") ' Gets the generated htm filename prefix
Dim SQL ' Search string, here I will open the table directly without searching for variables, search conditions can be written on their own
Sql= "SELECT * from Hotel where [city] = '" & City & ""
Dim oRs ' Data manipulation object
Dim pagecounts ' Implementing paging generation you have to know how many pages
Set oRs = Server.CreateObject ("ADODB. Recordset ")
oRS.Open sql,oconn,1,1 ' Find a hotel a table that equals city variables
Ors.pagesize=10 ' 10 Records as one page
Pagecounts=ors.pagecount ' How many pages to generate, looping to generate the use
Dim FS ' defines an FSO file object
Dim Folders ' holds folder name for generating static pages
Dim Filestart ' defines the Generate HTM file prefix
Set fs=server.createobject ("Scripting.FileSystemObject")
Dim I
For I=1 to Pagecounts ' starts looping through the generation of pages, that is, pagination generates
Page=i
Ors.absolutepage=i ' page number
Rowcount=ors.pagesize ' when page record number
Folders=server.mappath ("cityhtml")
if (fs. FolderExists (folders)) Then ' Determine if a folder exists
Else
Fs. CreateFolder (folders) ' does not exist then create cityhtml folder
End If
If I=1 Then
Filestart=htmlstartname ' If the first page is defined, the file name is the name of the pass value. For example Beijing is beijing.htm
Else
Filestart=htmlstartname&i ' If the second page is beijing+1 for example, there are two pages, i.e. I equals 2, then beijing2.htm so on ... (the. htm suffix is added later)
End If
Dim files ' definition generates a text file name variable
Dim Filez ' Define file path name variable
files=filestart& ". txt" is the name of this file
filez=folders& "\" & "files" text file path
' Album except file
Dim checkfile ' checks if the text file already exists, is deleted
Checkfile=server.mappath ("Cityhtml\" &Filestart& ". htm") ' Checks if the HTM file already exists, is deleted
if (fs. FileExists (checkfile)) Then ' Check if the HTM file already exists, is deleted
Dim DF ' definition file Object * Delete File Use *
Set Df=fs. GetFile (checkfile) ' defines the files to be removed
Df.delete ' album except file
End If ' judgment ends
Dim ts ' definition writes to file object
Set ts = fs.createtextfile (filez,true) ' Open write file content * * I write in the main text only the hotel name and static digital paging display * *
Ts.write ("<Html><Head><Title> generation" &City& "City Hotel </Title>" &vbcrlf) After that is the positive file content to be generated with the use of Response.Write
Ts.write ("<meta http-equiv=content-type content=text/html; Charset=gb2312> "&vbcrlf)
Ts.write ("<meta name=keywords content=" &city& "Hotel >" &vbcrlf)
Ts.write ("<link href= '/style/style.css ' rel= ' stylesheet type= ' text/css ' >Ts. Write ("<table width=760 cellspacing=0 cellpadding=0 align=center>" &vbcrlf&_
"<tr><td width= ' 100% ' >" &vbcrlf)
' Paging output starts
' Digital Paging program principle in this I will not say more, do not know friends can search the internet
Dim Page ' current page
Dim Page2 ' number paging variable
Dim s ' number paging variable
If Page=1 Then
Ts.write ("[Home page] [previous]")
Else
Ts.write ("<a href=" &HtmlStartName& ". htm" & "class=blue>[home]</a> <a href=" & Htmlstartname&replace (page-1,1, "") & ". htm" & "class=blue> previous page </a>")
End If
page2= (page-(page mod 10))/10
If Page2<1 then page2=0
For S=page2*10-1 to Page2*10+10
If S>0 Then
If S=cint (page) Then
Ts.write ("<font color= ' #000000 ' >[" & S & "]</font>")
Else
If S=1 Then
Ts.write ("<a href=" &htmlstartname&replace (s,1, "") & ". htm" & "class=blue>[" & S & "]</ A> ")
Else
Ts.write ("<a href=" &HtmlStartName&s& ". htm" & "class=blue>[" & S & "]</a>")
End If
End If
If S=ors.pagecount Then
Exit For
End If
End If
Next
If CInt (page) =ors.pagecount Then
Ts.write ("[Next page] [last]")
Else
Ts.write ("<a href=" &HtmlStartName&page+1& ". htm" & "class=blue>[next page]</a> <a href=" &HtmlStartName&ors.pagecount& ". htm" & "class=blue>[last]</a>")
End If
Ts.write ("</TD></TR>")
' Paging output ends
Don't ors.eof and rowcount>0 ' output hotel name
Ts.write ("<tr><td