19 Basic Tips for ASP (1)
Last Update:2017-02-28
Source: Internet
Author: User
Skill 1. Now the date Time command is
<%=now%> can
The
2.ASP method for obtaining data entry in form (from) is to use one of the built-in objects (object)-requect,
it varies by get,post.
3. If you want to write yourself in VB or other languages, the. dll file can be used by the ASP to register the DLL: DOS under
input Regsbr32 *.dll
4. Show five repeating sentences, the font is getting bigger
<% for I=1 to 5%>
<font size=<% =i%> color= #00ffff >
Fast ASP
</font>
<br>
<% Next%>
5. Transmit 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: Good Morning show, afternoon show Hello
<%
if time>+ #12:00:00 am# and time< #12:00:00 PM #
then
greeting= "Good morning!"
Else
greeting= "Hello!"
End If
%>
<%=greeting%>
Application of
8.<script> tag in ASP
Example:
<html>
<body>
<% call function1%>
</body>
</html>
<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 can be nested in layers. In addition, #include cannot be
within <%--%>
10.ASP method to obtain 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& ... ",
is then sent to the server.
such as: Action for www.abc.com, field name input data for Jack, Field age data is 15, then use the Get method for
http://www.abc.com?Name=jack&Age=15
two. Post: The client is routed to the server using HTTP information data
asp:
get: Use the input 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 Paradigm
such as: 〈a hery= "aspform.asp?" Name=jack&age=15 ">
Press 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>
Features: <select name= "Input2" >
<option>cool!
<option>handsome
<option>warmhearted
</select>
<input type=submit value= "OK" >
</form>
The content of
asp1b.asp
<html><body>
<% =request.querystring ("input1")%> Hi, your character is
<%= request.querystring ("Input2")%>
</body></html>
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 know the Name field to enter several values, without this name field, Count is 0