*******************************************************************************************
'Admin_News_Html.asp
'*******************************************************************************************
<%
Dim Rs,Sql,TempCount,NewsTitle,NewsAouth,NewsTime,NewsRecordset
Dim i,Strsql,Page,Totalpage,IndexPage,ListName,LastPage,LastId
Dim NextId,NextPage,EndPage
Set Rs=Server.CreateObject("Adodb.RecordSet")
Sql="Select * From Admin_News"
Rs.Open Sql,Conn,1,1
If Not Rs.Eof Then
NewsRecordset=Rs.RecordCount
Page=5
If(NewsRecordset Mod Page)=0Then
Totalpage=NewsRecordset\Page
Else
Totalpage=(NewsRecordset\Page)+1
End If
For k=1 To Totalpage
ym=ym&"<a href=""../news/News_List_"&Cstr(k)&".html"">"&k&"</a>"
Next
For j=1 To Totalpage
NewsTitle=""
TempCount=GetText(Server.MapPath("../temp/newsList.html"))
If j=1 Then
ListName="../news/News_List_1.html"
Else
ListName="../news/News_List_"&Cstr(j)&".html"
End If
For i=1 To Page
If Rs.Eof Then Exit For
IndexPage="<a href=""News_List_1.html"">首页</a>"
LastId=j-1
NextId=j+1
If LastId<=0 Then LastId=1
If NextId>=Totalpage Then NextId=Totalpage
LastPage="<a href=""News_List_"&Cstr(LastId)&".html"">上一页</a>"
NextPage="<a href=""News_List_"&Cstr(NextId)&".html"">下一页</a>"
EndPage="<a href=""News_List_"&Cstr(Totalpage)&".html"">尾页</a>"
NewsTitle=NewsTitle&"<tr>"&vbcrlf
NewsTitle=NewsTitle&"<td bgcolor=""#FFFFFF"">"&Rs("NewsTitle")&"</td>"&vbcrlf
NewsTitle=NewsTitle&"<td bgcolor=""#FFFFFF"">"&Rs("NewsAuthor")&"</td>"&vbcrlf
NewsTitle=NewsTitle&"<td bgcolor=""#FFFFFF"">"&Rs("NewsAddTime")&"</td>"&vbcrlf
NewsTitle=NewsTitle&"</tr>"
Rs.MoveNext
Next
TempCount=Replace(TempCount,"#newsTitle#",NewsTitle)
TempCount=Replace(TempCount,"#IndexPage#",IndexPage)
TempCount=Replace(TempCount,"#ym#",ym)
TempCount=replace(TempCount,"#LastPage#",LastPage)
TempCount=replace(TempCount,"#NextPage#",NextPage)
TempCount=replace(TempCount,"#EndPage#",EndPage)
Response.Write(TempCount)
Response.Write("正在生成:"&ListName&"列表...")
Response.Write("</br>")
SetText TempCount,ListName
Response.Write("正在生成:"&ListName&"列表成功...")
start = start + 1
If Rs.Eof Then Exit For
Next
End If
Function GetText(FilePath)
Dim STM
On Error Resume Next
Set STM =server.createobject("ADODB.Stream")
STM.Charset ="utf-8"
STM.Open
STM.LoadFromFile FilePath
GetText= STM.ReadText
End Function
Function SetText(FileConact,FilePath)
Dim Fso,FsoTxt
Set Fso=Server.CreateObject("Scripting.FileSystemObject")
Set FsoTxt=Fso.CreateTextFile(Server.MapPath(FilePath),true,false)
FsoTxt.Write(FileConact)
FsoTxt.Close
Set FsoTxt=Nothing
Set Fso=Nothing
End Function
%>
'******************************************************************
'模版页
'******************************************************************
<table cellpadding="1" cellspacing="1" style=" background-color:#3300FF; line-height:150%" width="50%">
#newsTitle#
<tr>
<td bgcolor="#FFFFFF" colspan="3" align="center" height="30px">
#IndexPage#
#LastPage#
#ym#
#NextPage#
#EndPage#
</td>
</tr>
</table>
本文转自 gutaotao1989 51CTO博客,原文链接:http://blog.51cto.com/taoyouth/1138842