asp可以编辑程序,也可以做网页

asp可以编辑程序,也可以做网页,第1张

分类: 电脑/网络 >> 程序设计 >> 其他编程语言

解析:

asp是在服务器端控制向客户端显示的

应用的脚本默认是VBSCRIPT

Vb本身就是一门编程语言,所以写程序当然没有问题

asp是一门专门应用于网页上的程序语言,但如果写前台的界面,还是用一些工具生成代码会更快

1 首先设计一个模板mubanhtml页面(如图所示),定义一些标签(图内红色字符串)

2 asp页面生成静态原理。先用fso读取mubanhtml,然后读取数据内容,用replace替换掉要用得标签即可,示例如下:

filepath=mubanhtml   '模板路径

set fso = ServerCreateObject("ScriptingFileSystemObject")

set f= fsoOpenTextFile(servermappath(""&filepath&""))

if not fsoFileExists(servermappath(""&filepath&"")) then

ReadTem="模版"&filepath&"不存在,请检查该路径文件。"

else

ReadTem=fReadAll

end if

fclose

set f=nothing

set fso=nothing

ReadTem=replace(ReadTem,"[title]","安福求生") '替换标题

ReadTem=replace(ReadTem,"[Keywords]","网店代销,网店代理") '替换关键字

ReadTem=replace(ReadTem,"[Description]","安福求生是网店导航网") '替换描述

ReadTem=replace(ReadTem,"[type001]","首页")

'定义变量type002,读取数据库,替换[type002]

Dim type002

type002=""

type002=type002&"<ul>"

set rs=serverCreateObject("adodbrecordset")

rsopen "select top 10  from link",conn,1,1

if rseof and rsbof then

type002=type002&"<li>还没有添加链接</li>"

else

do while not rseof

type002=type002&"<li>"&rs("siteName")&"</li>"

rsmovenext

loop

end if

rsclose

set rs=nothing

type002=type002&"</ul>"

ReadTem=replace(ReadTem,"[type002]",type002)

'根据ReadTem变量,生成新的静态页面

creatpath="/indexhtml"

set fso=servercreateobject("scriptingfilesystemobject")

set ffile=fsocreatetextfile(servermappath(""&creatpath&""))

ffilewrite""&ReadTem&""

ffileclose

responseWrite "生成新的:"&creatpath

set ffile=nothing

set fso=nothing

以上就是关于asp可以编辑程序,也可以做网页全部的内容,包括:asp可以编辑程序,也可以做网页、asp 如何使用fso在后台实现静态化前台页面、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/10635916.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-10
下一篇2023-05-10

发表评论

登录后才能评论

评论列表(0条)

    保存