The 19 most common basic skills in ASP, page 1/2

Source: Internet
Author: User

19 Basic ASP skills
1. The current date and time command is
<% = Now %>

2. asp uses a built-in object-requect to obtain table (from) data input,
It varies with get and post.

3. If you want to write the. dll file in VB or other languages, you must register the. dll file for ASP.
Enter regsbr32 *. dll

4. show five repeated sentences, and the font is getting bigger and bigger
<% For I = 1 to 5%>
<Font size = <% = I %> color = #00 FFFF>
Quick ASP
</Font>
<Br>
<% Next %>

5. Send a string to the client
Response. Write string
For example: <% response. Write "welcome" %>

6. Link to the specified URL address
Response. Redirect URL
For example:
<% Response. Redirect "Homepage. asp"
%>

* If the content of this. asp file has been transferred to the user for disconnection, an error will occur when redirect is used.

7. Integration of other languages with ASP:
For example, good morning is displayed in the morning, and hello is displayed in the afternoon.
<%
If time> + #12:00:00 am # And time <#12:00:00 #
Then
Greeting = "good morning! "
Else
Greeting = "Hello! "
End if
%>
<% = Greeting %>

8. <SCRIPT> mark the application in ASP
Example:

<HTML>
<Body>
<% Call function1 %>
</Body>
</Html>
<SCRIPT runat = server Language = JavaScript>
Function function1 ()
{
...
}
</SCRIPT>

9. # include other files
<! -- # Include virtual | file = "FILENAME" -->
Virtual refers to the virtual file address.
File represents the absolute file address.
For example:
<! -- # Include virtual = "/booksamp/test. asp" -->
<! -- # Include file = "/test. asp" -->

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

10. asp Method for retrieving table input data
: Get post
1. Get: After the user adds data to the URL, the format is "? Field 1 = input data 1 & Field 2 = input data 2 &...",
And then send it to the server.
For example, if action is www.abc.com, the input data of field name is Jack, and the data of field age is 15, the get method is
Http://www.abc.com? Name = Jack & age = 15

Ii. Post: the client transmits HTTP data to the server.
ASP:
Get: Use "input data = request. querystring (" field name ")" to retrieve the data appended to the URL.
Post: Use "input data = request. forml" (field name ")" to read HTTP information data fields.
* Request. querystring example
For example, <a Hery = "aspform. asp? Name = Jack & age = 15 ">
Follow this </a> <p> 〉
Name: <% = request. querystring ("name") %)
Age: <% = request. qeuerystring ("Age") %)
* Get example
· Aspturm. asp:
<Form action = "asp1b. asp" method = "get">
Name: <input type = text name = "input1" value = "Your name">
<P>
Feature: <select name = "input2">
<Option> cool!
<Option> handsome
<Option> warmhearted
</SELECT>
<Input type = submit value = "OK">
</Form>
Content of asp1b. asp
<HTML> <body>
<% = Request. querystring ("input1") %> Hi, your character is
<% = Request. querystring ("input2") %>
</Body>
11. Request. From
Syntax: request. From (name) [(INDEX) |. Count]
Name: field name
Index: when multiple values are input for the same field, index specifies the value to be read from the same field, ranging from 1
Request. From (name). Count
Count: the request. From (name). Count shows the number of values entered in the Name field. If this name field is not found, count is 0.

For example:
<%
Fori = 1 to request. fron ("input1"). Count
Response. Write Request. From ("input1") (I) & "<br>"
Next
%>
If input1 has two values
* If index is not used, specify which one to read. Available
<%
For each item request. From ("input "))
Repomse. Write item & "<br>"
Next
%>
You can also use "for each X in tewuest. From" to repeat the input values of all fields.

<% For each X in request. Form %>
Request. From (<% = x %) = <% = request. Form
(X) %> <br>
<% Next %>

12.
To obtain the client's TCP/IP Port:
For example, TCP/IP Port is <% = request ("server_port") %>
Use server_port to obtain the connection port information for receiving HTTP requests.

13.
the HTTP header information of http_accept_language can be used to obtain the user's language.
.
the following example identifies the language environment of the client and provides different pages.
<% Language = request. servervariables ("http_accept_language")
if language = "en" then %>

<% else %>

<% end if %>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.