首页源码asp动态网页源码,ASP学校网站源码

asp动态网页源码,ASP学校网站源码

编程之家2026-05-161163次浏览

大家好,asp动态网页源码相信很多的网友都不是很明白,包括ASP学校网站源码也是一样,不过没有关系,接下来就来为大家分享关于asp动态网页源码和ASP学校网站源码的一些知识点,大家可以关注收藏,免得下次来找不到哦,下面我们开始吧!

asp动态网页源码,ASP学校网站源码

急急急求两个ASP动态网页代码

1)asp生成html的方式

要生成文件肯空要用到FSO(FileSystemObject)组件,通过asp生成静态网页主要有两种方式:

a、生成的内容由多部分连接而成;

b、生成的内容基于模板生成。

2)方式1:生成的内容由多部分连接而成

步骤:

asp动态网页源码,ASP学校网站源码

a、设计要输出网页的布局

b、设计生成HTML的asp文件

例子:

输出网页的布局:

<html>

<head>

asp动态网页源码,ASP学校网站源码

<title>标题</title>

<style type="text/css">

<!--

.article_title{

font-size: 22px;

font-weight: bold;

text-align: center;

padding-top: 10px;

padding-bottom: 20px;

}

.content{

text-indent: 18px;

font-size: 16px;

line-height: 230%;

text-align: left;

}

.from{

font-size: 14px;

text-align: right;

padding-right: 15px;

padding-top: 15px;

}

.feature_bar{

font-size: 14px;

color:#999999;

text-align: center;

padding-bottom: 15px;

}

-->

</style>

</head>

<body>

<table width="80%">

<tr>

<td><div class="article_title">标题</div>

<div class="feature_bar">作者:录入时间:录入:</div>

<div class="content">内容</div>

<div class="from">来源:</div></td>

</tr>

</table>

</body>

</html>

把源代码中的所有的"替换成"",作用是在ASP中输出双引号。

设计asp文件:

<% Option Explicit%>

<html>

<head>

<title>ASP生成HTML</title>

<style type="text/css">

<!--

.align_right_top{

text-align: right;

vertical-align: top;

}

.align_left_10px{

text-align: left;

padding-left: 10px;

}

-->

</style>

</head>

<body>

<form method="post" action="?action=create">

<table width="80%">

<tr>

<td class="align_right_top">HTML文件名称:</td>

<td class="align_left_10px"><input name="HtmlFileName" type="text" id="HtmlFileName"/></td>

</tr>

<tr>

<td class="align_right_top">文章</td>

<td class="align_left_10px"><input name="title" type="text" id="title"/></td>

</tr>

<tr>

<td class="align_right_top">作者:</td>

<td class="align_left_10px"><input name="author" type="text" id="author"/></td>

</tr>

<tr>

<td class="align_right_top">录入:</td>

<td class="align_left_10px"><input name="editor" type="text" id="editor"/></td>

</tr>

<tr>

<td class="align_right_top">输入时间:</td>

<td class="align_left_10px"><input name="EditTime" type="text" id="EditTime"/></td>

</tr>

<tr>

<td class="align_right_top">文章内容:</td>

<td class="align_left_10px"><textarea name="content" cols="55" rows="20" id="content"></textarea></td>

</tr>

<tr>

<td class="align_right_top">来源:</td>

<td class="align_left_10px"><input name="from" type="text" id="from"/></td>

</tr>

<tr>

<td colspan="2" align="center"><input type="submit" name="Submit" value="提交"/></td>

</tr>

</table>

</form>

<%

if Trim(Request.QueryString("action"))="create" then

dim title, author, editor, EditTime, content, from, html

title=Trim(Request.Form("title"))

editor=Trim(Request.Form("editor"))

EditTime=Trim(Request.Form("EditTime"))

content=Trim(Request.Form("content"))

from=Trim(Request.Form("from"))

html="<html>"_'粘贴上面的修改后的输出网页布局的源代码

&"<head>"_‘并用 _与&把各行连接起来或删除多余空格使源代码写在一行

&"<title>"&title&"</title>"_

&"<style type=""text/css"">"_

&".article_title{"_

&"font-size: 22px;"_

&"font-weight: bold;"_

&"text-align: center;"_

&"padding-top: 10px;"_

&"padding-bottom: 20px;"_

&"}"_

&".content{"_

&"text-indent: 18px;"_

&"font-size: 16px;"_

&"line-height: 230%;"_

&"text-align: left;"_

&"}"_

&".from{"_

&"font-size: 14px;"_

&"text-align: right;"_

&"padding-right: 15px;"_

&"padding-top: 15px;"_

&"}"_

&".feature_bar{"_

&"font-size: 14px;"_

&"color:#999999;"_

&"text-align: center;"_

&"padding-bottom: 15px;"_

&"}"_

&"</style>"_

&"</head>"_

&"<body>"_

&"<table width=""80%"">"_

&"<tr>"_

&"<td><div class=""article_title"">"&title&"</div>"_

&"<div class=""feature_bar"">作者:"&author&"录入时间:"&EditTime&"录入:"&editor&"</div>"_

&"<div class=""content"">"&content&"</div>"_

&"<div class=""from"">来源:"&from&"</div></td>"_

&"</tr>"_

&"</table>"_

&"</body>"_

&"</html>"

dim HtmlFileName,HtmlFile, fs, FileStream

HtmlFileName=Trim(Request.Form("HtmlFileName"))

if instr(HtmlFileName,".html")=false then

HtmlFileName="NoName.html"

end if

HtmlFile=Server.MapPath(HtmlFileName)

set fs=CreateObject("Scripting.FileSystemObject")

set FileStream=fs.CreateTextFile(HtmlFile)

FileStream.WriteLine Html

FileStream.close

set FileStream=nothing

response.Write("<script>alert('生成"&HtmlFileName&"文件成功!');history.go(-1);</script>")

end if

%>

</body>

</htm>

把上面的asp文件保存放到服务器上即可运行

3)方式2:生成的内容基于模板生成

思想:

给模板asp传递参数,使用“MSXML2.XMLHTTP”读取基于参数传递的asp模板的网页源代码,

再使用FSO组件生成静态网页。

步骤:

a、设计有参数传递的asp模板

b、设计asp控制页

设计asp模板:(保存成template.asp)

<% Option Explicit%>

<%

dim HtmlFileName,title, author, editor,EditTime,content,from

HtmlFileName=Trim(Request.QueryString("HtmlFileName"))

title=Trim(Request.QueryString("title"))

author=Trim(Request.QueryString("author"))

editor=Trim(Request.QueryString("editor"))

EditTime=Trim(Request.QueryString("EditTime"))

content=Trim(Request.QueryString("content"))

from=Trim(Request.QueryString("from"))

%>

<html>

<head>

<title><%= title%></title>

<style type="text/css">

<!--

.article_title{

font-size: 22px;

font-weight: bold;

text-align: center;

padding-top: 10px;

padding-bottom: 20px;

}

.content{

text-indent: 18px;

font-size: 16px;

line-height: 230%;

text-align: left;

}

.from{

font-size: 14px;

text-align: right;

padding-right: 15px;

padding-top: 15px;

}

.feature_bar{

font-size: 14px;

color:#999999;

text-align: center;

padding-bottom: 15px;

}

-->

</style>

</head>

<body>

<table width="80%">

<tr>

<td><div class="article_title"><%= title%></div>

<div class="feature_bar">作者:<%= author%>录入时间:<%= EditTime%>录入:<%= editor%></div>

<div class="content"><%= content%></div>

<div class="from">来源:<%= from%></div></td>

</tr>

</table>

</body>

</html>

设计asp文件:(保存成html.asp)

<% Option Explicit%>

<html>

<head>

<title>ASP生成HTML</title>

<style type="text/css">

<!--

.align_right_top{

text-align: right;

vertical-align: top;

}

.align_left_10px{

text-align: left;

padding-left: 10px;

}

-->

</style>

</head>

<body>

<form method="post" action="?action=create">

<table width="80%">

<tr>

<td class="align_right_top">HTML文件名称:</td>

<td class="align_left_10px"><input name="HtmlFileName" type="text" id="HtmlFileName"/></td>

</tr>

<tr>

<td class="align_right_top">文章</td>

<td class="align_left_10px"><input name="title" type="text" id="title"/></td>

</tr>

<tr>

<td class="align_right_top">作者:</td>

<td class="align_left_10px"><input name="author" type="text" id="author"/></td>

</tr>

<tr>

<td class="align_right_top">录入:</td>

<td class="align_left_10px"><input name="editor" type="text" id="editor"/></td>

</tr>

<tr>

<td class="align_right_top">输入时间:</td>

<td class="align_left_10px"><input name="EditTime" type="text" id="EditTime"/></td>

</tr>

<tr>

<td class="align_right_top">文章内容:</td>

<td class="align_left_10px"><textarea name="content" cols="55" rows="20" id="content"></textarea></td>

</tr>

<tr>

<td class="align_right_top">来源:</td>

<td class="align_left_10px"><input name="from" type="text" id="from"/></td>

</tr>

<tr>

<td colspan="2" align="center"><input type="submit" name="Submit" value="提交"/></td>

</tr>

</table>

</form>

<%

function getHTTPPage(url)

dim Http

set Http=server.createobject("MSXML2.XMLHTTP")

Http.open"GET",url,false

Http.send()

if Http.readystate<>4 then

exit function

end if

getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")

set http=nothing

if err.number<>0 then err.Clear

end function

Function BytesToBstr(body,Cset)

dim objstream

set objstream= Server.CreateObject("adodb.stream")

objstream.Type= 1

objstream.Mode=3

objstream.Open

objstream.Write body

objstream.Position= 0

objstream.Type= 2

objstream.Charset= Cset

BytesToBstr= objstream.ReadText

objstream.Close

set objstream= nothing

End Function

%>

<%

if Trim(Request.QueryString("action"))="create" then

dim title, author, editor, EditTime, content, from, html

title=Trim(Request.Form("title"))

editor=Trim(Request.Form("editor"))

EditTime=Trim(Request.Form("EditTime"))

content=Trim(Request.Form("content"))

from=Trim(Request.Form("from"))

'读取传递参数后的模版源代码,地址根据具体情况而定

html=getHTTPPage(""_

&"?title="&title&"&editor="&editor&"&EditTime="_

&EditTime&"&content="&content&"&from="&content&"")

dim HtmlFileName,HtmlFile, fs, FileStream

HtmlFileName=Trim(Request.Form("HtmlFileName"))

if instr(HtmlFileName,".html")=false then

HtmlFileName="NoName.html"

end if

HtmlFile=Server.MapPath(HtmlFileName)

set fs=CreateObject("Scripting.FileSystemObject")

set FileStream=fs.CreateTextFile(HtmlFile)

FileStream.WriteLine Html

FileStream.close

set FileStream=nothing

response.Write("<script>alert('生成"&HtmlFileName&"文件成功!');history.go(-1);</script>")

end if

%>

</body>

</htm>

把template.asp与html.asp放在同一目录通过服务器运行后即可。

4)结论

通过比较可以看出,通过方式一生成的html文件源代码比较乱,而通过模板生成的html文件源代码跟原先模板的源代码一致。

哪位高手给写段ASP生成静态页的源码

网页生成静态Html文件有许多好处,比如生成html网页有利于被搜索引擎收录,不仅被收录的快还收录的全.前台脱离了数据访问,减轻对数据库访问的压力,加快网页打开速度.

像www.aspid.cn的主站就采用了TSYS生成html文件!

所以吟清最近对生成html比较感兴趣,看了不少文章,也有一点点收获.

1,下面这个例子直接利用FSO把html代码写入到文件中然后生成.html格式的文件<%

filename="test.htm"

if request("body")<>"" then

set fso= Server.CreateObject("Scripting.FileSystemObject")

set htmlwrite= fso.CreateTextFile(server.mappath(""&filename&""))

htmlwrite.write"<html><head><title>"& request.form("title")&"</title></head>"

htmlwrite.write"<body>输出Title内容:"& request.form("title")&"<br/>输出Body内容:"& request.form("body")&"</body></html>"

htmlwrite.close

set fout=nothing

set fso=nothing

end if

%>

<form name="form" method="post" action="">

<input name="title" value="Title" size=26>

<br>

<textarea name="body">Body</textarea>

<br>

<br>

<input type="submit" name="Submit" value="生成html">

</form>

2,但是按照上面的方法生成html文件非常不方便,第二种方法就是利用模板技术,将模板中特殊代码的值替换为从表单或是数据库字段中接受过来的值,完成模板功能;将最终替换过的所有模板代码生成HTML文件.这种技术采用得比较多,大部分的CMS都是使用这类方法.

template.htm'//模板文件<html>

<head>

<title>$title$ by aspid.cn</title>

</head>

<body>

$body$

</body>

</html>?

TestTemplate.asp'//生成Html<%

Dim fso,htmlwrite

Dim strTitle,strContent,strOut

'//创建文件系统对象

Set fso=Server.CreateObject("Scripting.FileSystemObject")

'//打开网页模板文件,读取模板内容

Set htmlwrite=fso.OpenTextFile(Server.MapPath("Template.htm"))

strOut=f.ReadAll

htmlwrite.close

strTitle="生成的网页标题"

strContent="生成的网页内容"

'//用真实内容替换模板中的标记

strOut=Replace(strOut,"$title$",strTitle)

strOut=Replace(strOut,"$body$",strContent)

'//创建要生成的静态页

Set htmlwrite=fso.CreateTextFile(Server.MapPath("test.htm"),true)

'//写入网页内容

htmlwrite.WriteLine strOut

htmlwrite.close

Response.Write"生成静态页成功!"

'//释放文件系统对象

set htmlwrite=Nothing

set fso=Nothing

%>

3,第三种方法就是用XMLHTTP获取动态页生成的HTML内容,再用ADODB.Stream或者Scripting.FileSystemObject保存成html文件。这句话是在蓝色理想上看到的,对XMLHTTP吟清还不熟悉正在找资料了解.找到一段XMLHTTP生成Html的代码参考一下.

<%

'常用函数

'1、输入url目标网页地址,返回值getHTTPPage是目标网页的html代码

function getHTTPPage(url)

dim Http

set Http=server.createobject("MSXML2.XMLHTTP")

Http.open"GET",url,false

Http.send()

if Http.readystate<>4 then

exit function

end if

getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")

set http=nothing

if err.number<>0 then err.Clear

end function

'2、转换乱玛,直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换

Function BytesToBstr(body,Cset)

dim objstream

set objstream= Server.CreateObject("adodb.stream")

objstream.Type= 1

objstream.Mode=3

objstream.Open

objstream.Write body

objstream.Position= 0

objstream.Type= 2

objstream.Charset= Cset

BytesToBstr= objstream.ReadText

objstream.Close

set objstream= nothing

End Function

txtURL=server.MapPath("../index.asp")

sText= getHTTPPage(txtURL)

Set FileObject=Server.CreateObject("Scripting.FileSystemObject")

filename="../index.htm"

Set openFile=FileObject.OpenTextfile(server.mapPath(filename),2,true)'true为不存在自行建立

openFile.writeline(sText)

Set OpenFile=nothing

%>

<script>

alert("静态网页生成完毕");

history.back();

</script>

asp网站源代码

在局域网里搭建一个web服务器,固定该机的内网IP,要win2003系统,XP的不行,因为IIS连接数有限制,搭建好,把程序放上去,其他电脑直接输入这台服务器的IP地址就可以访问了。

如果要外网登陆,要先把局域网的路由器映射到这台服务器上,一般是在路由器里设置DMZ主机,然后填上服务器的内网IP。

外网访问时是要输入外网的IP,可以上IP138查询到。

如果你们宽带是固定IP的话申请个域名指向这个IP就行了,如果不是固定IP,就需要使用动态域名,现在常用的是“花生壳”

关于asp动态网页源码和ASP学校网站源码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

ai画图(怎么用AI画图)c语言基础知识入门教程,c语言入门教程