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
res
相关文档:
我写了个程序,本地运行完全正常,上传到服务器在服务器上操作有时候能正常操作,但是运行一会儿就服务器连接超时,然后就不能正常操作了,关闭网页,打开还是不能连接数据库操作,等半小时后或者更久又能正常了,请问这个是怎么回事?本地随时都能正常运行切找不出任何问题。高手帮帮忙啊! ......
<%@ Language="VBScript" %>
<%' Option Explicit %>
<%
'不使用输出缓冲区,直接将运行结果显示在客户端
Response.Buffer = False
'声明待检测数组
Dim ObjTotest(26,4)
ObjTotest(0,0) = "MSWC.AdRotator"
ObjTotest(1,0) = "MSWC.BrowserType"
ObjTotest(2,0) = ......
<%
'下面是最具技术含量的函数了,哈哈~
'增加数据库字段
function addziduan(ziduanming,ziduanleixing)
on error resume next
fldname = ziduanming
if ziduanleixing=1 or ziduanleixing=4 then
fldtype = "VarChar"
fldsize = 255
elseif ziduanleixing=2 or ziduanleixing=3 then
fldtyp ......
<%
set rs=server.CreateObject("adodb.recordset")
ids=""
call lids(keys)
ids=keys&ids
sql="select id,title,pic_xiao,content from "&tables&" where lid in("&ids&") "
......
俩函数搞定asp的orm映射
orm必须用到实体类,像C#这样的语言 写实体类挺痛苦的,除非用工具
而asp有个好处,因为他可以动态构建一个字符串并把此字符串动态解析为代码,也就是他的 execute 和 ExecuteGlobal 俩函数
下面这个函数是 实体类生成器 只要传入列名字符串就能生成 一个全局可用的类
'定义一个实体类
' ......