19 Basic Tips for ASP
1. The present date Time command is
<%=now%> can
The 2.ASP method for obtaining data entry from a form is to use a built-in object (-requect).
It varies with get,post.
3. If you want to write your own VB or other language, the. dll file should be registered with the DLL for ASP: DOS
Enter Regsbr32 *.dll
4. Show five repeating sentences, fonts getting bigger
<% for I=1 to 5%>
<font size=<% =i%> color= #00ffff >
Fast ASP
</font>
<br>
<% Next%>
5. Send string to Client
Response.Write string
such as: <% Response.Write "Welcome"%>
6. Link to the specified URL address
Response.Redirect URL
Such as:
<% Response.Redirect "Homepage.asp"
%>
* But if this. The ASP's file content has been routed to the user, and then an error occurs when the redirect is used.
7. Integration of other languages with ASP:
Such as: Morning display, good afternoon show you
<%
If time>+ #12:00:00 am# and time< #12:00:00 PM #
Then
Greeting= "Good morning!"
Else
greeting= "Hello!"
End If
%>
<%=greeting%>
The application of 8.<script> tag in ASP
Cases:
<body>
<% Call Function1%>
</body>
<script Runat=server language=javascript>
function Function1 ()
{
...
}
</script>
9. #include including other documents
<!--#include virtual|file= "filename"-->
Virtual refers to a fictitious file address.
File represents an absolute filename address.
Such as:
<!--#include virtual= "/booksamp/test.asp"-->
<!--#include file= "/test/test.asp"-->
And you can nest layers. In addition, #include cannot be within <%--%>
10.ASP method to get form input data
: Get POST
A. Get: The client adds the data to the URL after the format is "? Field 1 = input data 1& field 2 = input data 2& ... ",
And then send it to the server.
For example: Action is www.abc.com, field name input data is Jack, field age data is 15, then use the Get method to
Http://www.abc.com?Name=jack&Age=15
Two. Post: The client uses HTTP information data to transfer to the server
In asp:
Get: Use "Enter data = request.querystring (field name)" To remove the data attached to the URL.
Post: Use the Enter data =request.forml (field name ")" to read the HTTP information data fields.
* Request.QueryString Example
such as: 〈a hery= "aspform.asp?" Name=jack&age=15 ">
Click here 〈/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>
Features: <select name= "Input2" >
<option>cool!
<option>handsome
<option>warmhearted
</select>
<input type=submit value= "OK" >
</form>
The content of asp1b.asp
<% =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 entered in the same field, the pointer value index specifies the value to read the same field, ranging from 1 to
Request. From (name). Count
Count: By request. The From (name). Count knowable Name field enter several values, if no this name field, Count is 0
The following example:
<%
Fori=1 to Request.fron ("INPUT1"). Count
Response.Write Request. From ("Input1") (I) & "<br>"
Next
%>
If the INPUT1 has two values, it shows
* If the index is not used to specify which to read. Available
〈%
For each item request. From ("Input"))
Repomse.write Item & "<br>"
Next
%>
You can also use the for each x in Tewuest. From "repeatedly gets the input values for all fields.
<% for each x in request. Form%>
Request. From (<%=x%) =<%=request. Form
(x)%> <br>
<% Next%>
12.
To obtain the client TCP/IP Port method:
For example: TCP/IP port is <%=request ("Server_port")%>
Use Server_port to receive connection port information for HTTP request
13.
Using Http_accept_language HTTP header information, you can get the user-side language
Environment.
The following example determines the locale of the client and gives a different page.
<% language=request.servervariables ("Http_accept_language")
If language= "en" then%>
<!--#include file= "english.asp" >
<% Else%>
<!--#include file= "china.asp" >
<% End If%>
Current 1/2 page
12 Next read the full text