Asp深度揭密(上)

2016-01-29 19:19 0 1 收藏

Asp深度揭密(上),Asp深度揭密(上)

【 tulaoshi.com - ASP 】

  一、Asp基本知识

1.Asp是Active Server Pages的简称,是解释型的脚本语言环境;
2.Asp的运行需要Windows操作系统,9x下需要安装PWS;而NT/2000/XP则需要安装Internet Information Server(简称IIS);
3.Asp和JSP的脚本标签是“<%%”,PHP的则可以设定为多种;
4.Asp的注释符号是“'”;
5.使用附加组件,可以扩展Asp的功能。
from www.knowsky.com

例子:

HelloWorld_1.asp
<%="Hello,world"%

效果:
Hello,world


HelloWorld_2.asp
<%
for i=1 to 10
response.write "Hello,world"
next
%

效果:
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world
Hello,world

注意:Asp不区分大小写;变量无需定义也可使用,转换方便;语法检查很松。


二、Asp内置对象的使用:

可以使用下面的任何ASP内置对象,而不必在ASP脚本中特别声明。

1.    Request:

定义:可用来访问从浏览器发送到服务器的请求信息,可用此对象读取已输入HTML表单的信息。

集:
Cookies:含有浏览器cookies的值
Form:含有HTML表单域中的值
QueryString:含有查询字符串的值
ServerVariables:含有头和环境变量中的值

例子:

request_url.asp
<%
'获取用户输入,并存入变量
user_id=request.querystring("user_id")
user_name=request.querystring("user_name")

'判断用户输入是否正确
if user_id="" then
response.write "User_id is null,please check it"
response.end
end if
if user_name="" then
response.write "User_name is null,please check it"
response.end
end if

'打印变量
response.write user_id&"<br"
response.write user_name
%

效果:
当访问http://10.1.43.238/course/request_url.asp?user_name=j时:
User_id is null,please check it
当访问http://10.1.43.238/course/request_url.asp?user_name=j&user_id=my_id时:
my_id
j

思考:变量是如何在URL中传递和被Asp页面获取的?


request_form.htm
<style type="text/css"
<!--
.input {background-color: #FFFFFF; border-bottom: black 1px solid;border-left: black 1px solid; border-right: black 1px solid;border-top: black 1px solid; color: #000000;font-family: Georgia; font-size: 9pt;color: midnightblue;}
a:link {color: #1B629C; text-decoration: none}
a:hover {color: #FF6600; text-decoration: underline}
a:visited {text-decoration: none}
--
</style

<center
<form name="course" action="request_form.asp" method="post"
User_id:<input type="text" name="user_id" maxlength="20" class="input"<br<br
User_name:<input type="text" name="user_name" maxlength="30" class="input"
</form
<br<br
<a href="javascript:document.course.submit();" 提 交 </a
</center

request_form.asp
<%
'获取用户输入,并存入变量
user_id=request.form("user_id")
user_name=request.form("user_name")

'判断用户输入是否正确
if user_id="" then
response.write "User_id is null,please check it"
response.end
end if
if user_name="" then
response.write "User_name is null,please check it"
response.end
end if

'打印变量
response.write user_id&"<br"
response.write user_name
%

注意:form的action的指向,request_form.asp和request_url.asp在源代码上的区别?

2.    Response:

定义:用来向浏览器回发信息,可用此对象从脚本向浏览器发送输出。

集:
Cookies:在浏览器中加入一个cookie

方法:
End:结束脚本的处理
Redirect:将浏览器引导至新页面
Write:向浏览器发送一个字符串

属性:
Buffer:缓存一个ASP
CacheControl:由代理服务器控制缓存
ContentType: 规定响应的内容类型
Expires:浏览器用相对时间控

来源:https://www.tulaoshi.com/n/20160129/1509044.html

延伸阅读
标签: ASP
  利用asp结合javascript或vbscript可以生成动态的web页面。在将这种方法用于实际应用中时,不可避免的要将结果打印输出。我们同样可以将查询结果整理后输出,并用浏览器工具栏上的打印按钮直接打印输出。以下程序是访问sql server 自带的数据库pubs中的sales表,服务器和工作站端都采用vbscript。当工作站端采用javascript时,可用naviga...
深度黑暗:重装上阵 菜单界面翻译 深度黑暗:重装上阵 试玩版视频攻略 深度黑暗:重装上阵 试玩版图文攻略 ...
深度解析光圈 很大程度上说,摄影就是光圈、快门、ISO的运用。不论你有没有基础,是刚学摄影还是已经是老鸟,这篇史上最强的光圈解析文章都会让你觉得受益匪浅。 核心内容: 1、剖析光圈属性 2、详解光圈挡位 3、景深那些事儿 4、光圈与焦外效果 5、镜头选购窍门 什么是光圈? 摄影总是充斥...
羊水深度 羊水深度是什么意思呢?相信很多妈妈都不知道,其实羊水深度为医学专业名词,是判断羊水多少的一个重要指标。 羊水多,则胎儿可以健康成长;羊水少,就可以在胎儿临产期造成胎粪淤积,甚至早产或窒息。 孕24周羊水深度是多少?羊水深度说明什么?羊水指数和羊水深度是什么?老婆去做了羊水深度标准是多少? 羊水深度标准 羊水...
标签: 男人养生
揭密“男科体检”详情   60岁以上:60岁以后,男性前列腺组织纤维化严重,极易患前列腺增生、肥大,所以建议PSA应该每年查一次,B超1—2年做一次。对于需要憋尿进行B超检查的男性,可以在去医院前先排空尿液,到医院后再饮用500—1000毫升矿泉水。 你曾为“那里”(生殖器)发痒、分泌物异...

经验教程

342

收藏

64
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部