《ASP网络编程》学习笔记之二

来源:互联网 发布:产品介绍动画制作软件 编辑:程序博客网 时间:2024/04/30 13:37

 1、使用Response对象在网页上输出内容
<HTML>
<HEAD>
<TITLE>一个简单的ASP程序</TITLE>
</HEAD>
<BODY>
<%
if hour(now) = 0 then
   response.write "现在是午夜。 "
end if
if hour(now) = 12 then
   response.write "现在是中午。"
end if
if (hour(now) >=1) and (hour(now) <= 11) then
   response.write "上午" & hour(now) & "点。"
end if
if (hour(now) >= 13) and (hour(now) <=23) then
   response.write "下午" & hour(now) -12 & "点。"
end if
%>
</BODY>
</HTML>

2、For循环
<HTML>
   <HEAD>
   <TITLE>创建一个10*10的表格 </TITLE>
   </HEAD>
   <BODY>
   <P align=center>创建10*10的表格</P>
   <table aligh=center cellspacing=0 cellpadding=10 border=1>
   <%
   For intRow = 1 to 10
       Response.write "<tr>"
       For intCol = 1 to 10
           Response.write "<td>" & (intRow - 1) * 10 + intCol & "</td>"
       Next
       Response.write "</tr>"
    Next
    %>
    </table>
    </Body>
</HTML>

3、CSS文件
<style type="text/css">
<!--
body,table,tr,td {color:#888888;font-size: 9pt; text-decoration: none}
A:link {color:#333333; text-decoration:none}
A:visited {color: #333333; text-decoration:none}
A:active {color: #CC0001; text-decoration:none}
A:hover { color: #CC0001; text-decoration: underline}
-->
</style>
      

3、Do loop循环
<HTML>
<HEAD>
<TITLE>倒三角形图案</TITLE>
<link href="../css.css" rel=stylesheet" type="text/css">
</HEAD>
<BODY>
<table align=center>
   <tr><td>
<%
intRow=15
intCol=1
Do while

4、过程
<%
function tranStr(oldStr) '转换字符串函数
  dim newStr
  newStr = trim(oldStrr)
  newStr = replace(newStr," ' "," ' ' ")
  tranStr = newStr
end function
%>

5、Err对象无错误显示
<html>
<head><title>没有设置 Option Explicit 语句</title></head>
<body>
<%
Dim intYourSalary
intYourSalary = 100000
Response.write ("您的薪水是 $" & CCur (intYorSalary) & "。<BR>")
%>
</body>
</html>

6、Err对象有错误显示
<%option explicit %>
<html>
<head><title>错误处理 </title></head>
<body>
<%
On Error Resume Next
dim intYourSalary
intYourSalary = 100000
Response.write ("您的薪水是 $" & CCur (intYorSalary) & ".<BR>")
IF Err.number <>0 THEN
     response.write "错误号是: " & Err.number & "<br>"
     response.write "错误号是" " & Err.Description
end if
%>
</body>
</html>

原创粉丝点击