当前位置: 首页 > 图文教程 > 网络编程 > ASP > Asp深度揭密(上)

ASP
使用ASP和Word进行服务器端拼写检查
文本中首字母全改为大写
检测整数和长整数的函数
谈谈如何在不支持数据库的asp主页上运用ado
在多行文本框中显示读取信息
生成一个不重复的随即数字
网上追捕(很多实用的port)
用javascript隐藏超级链接的真实地址
给浏览器的滚动条加上颜色
asp+中是如何连接数据库ado+的
几个对图形进行动态处理的dhtml代码
域名登记查询(whois)很复杂吗--方法一
域名登记查询(whois)很复杂吗--方法二
用ASP创建多栏选项列表
asp中的一个奇怪的函数
瞒天过海html文件技术一瞥
如何在服务器上保存一定时间的信息
用ASP发 WAP MAIL(=)
创建弹出式“每日提示”窗口
用两行代码在浏览器中实现文件上传

ASP 中的 Asp深度揭密(上)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 163 ::
收藏到网摘: n/a

       一、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的功能。
  
  例子:
  
  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
  <%
  '获取用