Share 19 basic skills of ASP scripting language

怪我咯
Release: 2017-03-30 13:35:21
Original
1182 people have browsed it

 ASP (English full name Active Server Pages) is a programming environment in which HTML, scripting languages, and components can be mixed to create powerful server-side Internet applications. If you have previously created a site that mixed HTML, scripting languages, and components, you can add ASP code to it. Moreover, you can also include some business logic rules through the use of components. Components can be called by scripts or other components. The following lists nineteen basic techniques for using ASP script language:
1. The current date and time command is

The following is a quotation fragment:
<%=now%>
each item request.From("input"))
repomse.write item &"
"
next
%>

 Also available" for each x in tewuest.From"Repeatly obtain the input values ​​​​of all fields.

2. The method for ASP to obtain data input from form (from) is to use a built-in object (object)—Request, which It varies with get and post.

 3. If you want to write it yourself in VB or other languages, and the .dll file can be used by ASP, you need to register the DLL file: enter regsbr32 *.dll under DOS.

 4. Display five repeated sentences, with the font size getting larger and larger.

The following is a quotation fragment:
<% for i=1 to 5 %>
color=#00ffff>
Fast ASP



<% next %>

 5. Send the string to the client

response.write string

The following is a reference fragment:
 For example: <% response.write "Welcome" %>

 6. Link to the specified URL address

 response .redirect url
 The following is a reference fragment:
For example: <% response.redirect "homepage.asp">

 *But if the content of this .ASP file has been transmitted to the user, An error will occur when redirecting is used again.

7. Combination of other languages ​​​​and ASP:
The following is a quotation fragment:
For example: Good morning is displayed in the morning, Hello is displayed in the afternoon
<%
if time>+ #12:00:00 AM# and time<#12:00:00 PM
#then
greeting="Good morning!"
else
greeting="Hello!"
end if
%>
<%=greeting %>

 8. Application of <script> tag in ASP<br><br>The following is a quotation fragment:<br>Example: <br><html> <br><body> <br><% call function1 %> <br></body> <br></html> <br><script runat=server language=javascript> <br>function function1() <br>{ <br>... <br>} <br></script>

 9.#include includes other files

 

virtual refers to the virtual file address.

file represents the absolute file address.

For example:

The following is a quotation fragment:



And can be nested layer by layer. In addition, #include cannot be within <%--%>.

10. ASP method to obtain form input data: GET POST

1.get: After the client adds the data to the URL, the format is "?Field 1=Input Data 1&Field 2= Enter data 2&..." and then send it to the server.

For example: actionwww.abc.com, the input data in field Name is jack, and the data in field age is 15.

2. Post: The client uses http information data to be transmitted to the server ASP:

Get: Use "input data = Request.QueryString ("field name")", which will be appended to the URL The data is taken out.

Post: Use "input data = Request.Forml" (field name ")" to read the HTTP information data field.
The following is a quotation fragment:
* Request.QueryString example
For example: 〈A hery="aspform.asp?Name=jack&Age=15">
Click here〈/A〉〈p〉
Name:<%=request.QueryString("Name")%)
Age:<%=request.QeueryString("Age")%)
* get Example
·aspturm. asp:


Name:
< ;p>
Features:

content of asp1b.asp

<% =request.querystring("input1") %> hi, your character is
<%= request.querystring("input2") %>
 

11.request.From

Syntax: request.From (name)[(index)|.count]

Name: Field name

Index: When multiple values ​​are entered in the same field, the pointer value index specifies the one to read the same field Value, ranging from 1 to request.From(name).count

Count: From request.From(name).count, you can know how many values ​​​​are entered in the name field. If there is no such name field, count is 0

The following example:

The following is a quotation fragment:
<%
forI=1 to request.fron("input1").count
response.write request.From ("input1")(I)&"
"
next
%>  

If input1 has two values, both will be displayed if index is not used to specify which one to read. Available

The following is a quote fragment:
〈%
for
<% for each x in request.Form %>
request.From (<%=x% )=<%=request.Form
(x)%>

<% next %>

 12. Method to obtain the client TCP/IP port:

For example: tcp/ip port is <%=request("server_port")%>

Use server_port to get the connection port information for receiving HTTP requests.

 13. Through the HTTP header information of HTTP_ACCEPT_LANGUAGE, the user's language environment can be obtained.

The following example determines the language environment of the client and gives different pages.

The following is a quotation fragment:
<% language=request.servervariables("HTTP_ACCEPT_LANGUAGE")
if language="en" then %>


The above is the detailed content of Share 19 basic skills of ASP scripting language. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template