亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

你好,我該怎么把ASP轉成HTML?需要怎么操作?

你好,我該怎么把ASP轉成HTML?需要怎么操作?

鳳凰求蠱 2021-08-22 18:14:58
我想把ASP轉換成HTML格式的頁面,不知道怎么辦?
查看完整描述

2 回答

?
陪伴而非守候

TA貢獻1757條經驗 獲得超8個贊

利用模板技術把asp轉換成html

<%
sub asp2htm()
'定義Recordset對象
Set rs=Server.CreateObject("ADODB.Recordset")
'設置rs的ActiveConnection屬性,綁定到連接
Set rs.ActiveConnection = Conn
'設置游標類型
rs.CursorType = 3
sql="select * from article where title='"&title&"'"
rs.open sql
do while not rs.eof
ArticleID=rs("ArticleID")
title=rs("title")
author=rs("Author")
copyfrom=rs("copyfrom")
hits=rs("hits")
updatetime=rs("updatetime")
editor=rs("editor")
content=rs("content")
Key=rs("key")
content = replace(content,"../UploadFiles/","../../UploadFiles/") '解決圖片路徑問題
'title = Request("title") '獲取標題
'content = Request("content") '獲取內容
'path = Server.MapPath("html") '保存路徑
tnow = now()
fname = year(tnow)&FormatNumber(month(tnow)/100,2,Flase)&FormatNumber(day(tnow)/100,2,Flase)&FormatDateTime(tnow,3)&ArticleID
fname = replace(fname,".","")
fname = replace(fname,":","")
fname = fname & ".htm" '生成HTML文件的文件名

Set fso = CreateObject("Scripting.FileSystemObject")
Set ftemp = fso.OpenTextFile(Server.MapPath("asp2htm/templates.txt"), 1)
TempData = ftemp.ReadAll '讀取模板內容
ftemp.Close

TempData = Replace(TempData,"#title#",title) '寫入標題
TempData = Replace(TempData,"#content#",content) '寫入內容
TempData = Replace(TempData,"happig",author)
TempData = Replace(TempData,"本站原創",copyfrom)
'TempData = Replace(TempData,"#click#",hits)
TempData = Replace(TempData,"2006-11-9 15:56:13",updatetime)
TempData = Replace(TempData,"admin",editor)
TempData = Replace(TempData,"7744",articleid)
TempData = Replace(TempData,"|asp,自動生成,html,優化|",Key)
TempData = Replace(TempData,"7744",ArticleID)

Set fhtml = fso.CreateTextFile(path&"\"&fname)
fhtml.WriteLine TempData '保存文件
fhtml.Close
Set fso = nothing

sql="update Article set content='"&fname&"' where articleid="&cint(articleid)
cmd(sql)
rs.movenext
response.Write("添加"&title&"成功<br>")
response.Clear()
Response.Flush()
loop
call cdb(rs)
'將信息存入數據庫略。
end sub
%>



查看完整回答
反對 回復 2021-08-30
  • 2 回答
  • 0 關注
  • 309 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號