asp下最常用的19个基本技巧

asp的19个基本技巧 1.现在的日期时间命令是 %=now%即可 2.ASP取得表格(from)数据输入的方法,是使用一个内置的对象(object)—Requect, 它以get,post而异。 3.若要自己用VB或其它语言编写,.dll文件供ASP使用需将DLL文件注册方可:DOS下 输入regsbr32*.dll 4.显示五个重复的句子,字体越来越大 %fori=1to5% fontsize=%=i%color=#00ffff 快速ASP /font br %next% 5.传送字符串到用

作者: 来源: 时间: 17-11-23 15:42:46

asp的19个基本技巧 
1. 现在的日期时间命令是
<%=now%> 即可

2.ASP取得表格(from)数据输入的方法,是使用一个内置的对象(object)—Requect,
它以get,post而异。

3.若要自己用VB或其它语言编写,.dll文件供ASP使用需将DLL文件注册方可:DOS下
输入 regsbr32 *.dll

4.显示五个重复的句子,字体越来越大
<% for i=1 to 5 %>
<font size=<% =i %> color=#00ffff>
快速ASP
</font>
<br>
<% next %>

5.传送字符串到用户端
response.write string
如:<% response.write "Welcome" %>

6.链接到指定的URL地址
response.redirect url
如:
<% response.redirect "homepage.asp"
%>

*但是如果此.ASP的文件内容已经传送到用户断,则再用redirect时会发生错误。

7.其他语言与ASP的结合:
如:早上显示早安,下午显示你好
<%
if time>+#12:00:00 AM# and time<#12:00:00 PM #
then
greeting="早安!"
else
greeting="你好!"
end if
%>
<%=greeting %>

8.<script>标记在ASP中的应用
例:

<html>
<body>
<% call function1 %>
</body>
</html>
<script runat=server language=javascript>
function function1()
{
...
}
</script>

9.#include 包括其它文件
<!--#include virtual|file="filename"-->
virtual指虚拟的文件地址。
file 代表绝对的文件地址。
如:
<!--#include virtual="/booksamp/test.asp"-->
<!--#include file="/test/test.asp"-->

而且可以层层嵌套。另外#include 不能在<%--%>之内

10.ASP取得表格输入数据的方法
:GET POST
一.get:用户端将数据加到URL后,格式为”?字段1=输入数据1&字段2=输入数据2&...",
再将其送到服务器。
如: action为www.abc.com, 字段Name输入数据为jack,字段age的数据为15,则用get方法为
http://www.abc.com?Name=jack&Age=15

二.post:用户端用http信息数据传送到服务器
ASP中:
get:使用“输入数据= Request.QueryString("字段名")",将附加于URL的数据取出。
post:使用“输入数据=Request.Forml"(字段名")",读取HTTP信息数据字段。
* Request.QueryString范例
如:〈A hery="aspform.asp?Name=jack&Age=15">
按此〈/A〉〈p〉
Name:<%=request.QueryString("Name")%)
Age:<%=request.QeueryString("Age")%)
* get 范例
·aspturm.asp:
<form action="asp1b.asp" method="get">
姓名: <input type=text name="input1" value="http://www.popasp.com/Your name">
<p>
特征: <select name="input2">
<option>cool!
<option>handsome
<option>warmhearted
</select>
<input type=submit value="http://www.popasp.com/ok">
</form>
asp1b.asp的内容
<html><body>
<% =request.querystring("input1") %> hi, your character is
<%= request.querystring("input2") %>
</body></html>
11.request.From
语法: request.From(name)[(index)|.count]
name:字段名
index:当同一字段输入多个值时,指针值index指定要读取同一字段的那一个值,范围由1到
request.From(name).count
count:由request.From(name).count可知name字段输入几个值,若无此name字段,count为0


如下例:
<%
forI=1 to request.fron("input1").count
response.write request.From("input1")(I)&"<br>"
next
%>
若input1有两个值则都显示出
*若未采用index指定读取哪个.可用
〈%
for each item request.From("input"))
repomse.write item &"<br>"
next
%>
也可用" for each x in tewuest.From"重复取得所有字段的输入值。

<% for each x in request.Form %>
request.From (<%=x%)=<%=request.Form
(x)%> <br>
<% next %>


12.
获取客户端TCP/IP端口的方法:
如: tcp/ip port is <%=request("server_port")%>
使用server_port可以得到接收HTTP request的连接port信息


13.
通过HTTP_ACCEPT_LANGUAGE的HTTP表头信息,可以得到用户端的使用语言
环境.
以下例子判断用户端的语言环境,给出不同的页面.
<% language=request.servervariables("HTTP_ACCEPT_LANGUAGE")
if language="en" then %>
<!--#include file="english.asp">
<% else %>
<!--#include file="china.asp">
<% end if%>
11
22
33
隐藏区块

会员注册

本功能为预留功能,暂不支持注册 ^_^

Login

社交帐号登陆

使用以下任意帐号可登陆本站

Close section
Close

联系我们

关于5UCMS 您有任何需求 均可以留言给我们