Web development tool: Efficient and easy to learn ASP

Source: Internet
Author: User
Tags date functions html tags include pack variable browser cache client

And reader the strange, up such a nondescript name, rather than "ASP preliminary (Introduction, Foundation)", for two reasons: a fear of too corny, but more important is afraid of many wandering in the ASP threshold outside the home made group even the content has never met to escape, it is a pity! In fact, as long as you have the experience of making Web pages, you should know the point of ASP, otherwise, your homepage I am afraid not enough "cool". How do you say that? If you have been writing the. htm or. html file as a home page, it will be strange how to display the IP address and the number of people online on the home page. How to let the client not get the source code of their own home page files? Or how to achieve the current very fashionable personalized services (according to the different requirements of the browser automatically generated pages), or how to do their own production counters, message thin, automatic friendship links even to achieve electronic shopping? Then, when you have finished reading this lecture, I am afraid that the principle of the realization of these things is so simple. If that's the case, keep looking down.

First, let us understand the basic requirements of learning ASP.
1. The minimum personal configuration required for ASP to start:
(1) Understand a little HTML knowledge (have the experience of maintaining the production of web pages);
(2) A bit of database knowledge, such as using Microsoft Access or using the. mdb database.
(3) It is best to have a little programming foundation (preferably VB Series, request will use if ...) Then ... End If Select a spoke statement and a loop statement. If you don't have any programming basics, just try it.
2. debugging, running the software environment required by asp:
(1) WIN9X+PWS (Win98 CD-ROM "\add-ons\pws\setup.exe" installed on the line). As for how to install the personal Web Server, many magazines are introduced (not too much Oh, computer business intelligence last year, an "ASP personal Hands-on Guide"), in fact very simple, no article write so complex. If this is not done, I would suggest that you call the editorial Office for advice.
(2) or using Windows nt4.0+iis4.0 (in the Windows NT4.0 Option Pack installer), it is better to use this combination if you want to build an intranet in your organization.
After installation, if you enter http://localhost/default.asp in the browser, the installation succeeds (by default, your home page file should be placed under the "\inetpub\wwwroot" directory). If you want to upload a debugged ASP file to a remote home server, you must be sure that the server supports ASP, but there are not many free home pages that are currently declared to support ASP, here are two: Dongguan Windows (http://www.homecn.com/) and NET668 ( http://freenet.net668.net/), you can test my ASP file run results: http://202.103.176.81/grun/kissher/asp/ipfound2.asp.
3. ASP Learning Support:
(1) ASP technology website: http://www.chinasp.com/, from here also can find some ASP related English site.
(2) ASP dynamic Network: http://active.t500.net/
(3) Windows NT4.0 Option Pack description file and active Server Pages3.0 documentation.
(4) Visual Studio6.0 's MSDN Library CD contains two files Asp.chm, aspdoc.chm are ASP Help files, no downloads to my Site http://wuf.bentium.net (and downloads all the source programs in this article).
(5) The purpose of this lecture is only to teach you to dots, using ASP (including direct use of the ASP program that can be downloaded) in your home page, to be useful first. If you want to go further, it is recommended to buy an ASP handbook, such as: "ASP Practice classic" (China Railway Press, Lin Jinlin).

Second, try it yourself. To enhance perceptual knowledge, we first use two examples to illustrate how to edit and work with ASP files. Open the Windows Attachment Notepad, enter the following code, save as Wuf1.asp (if you have any questions, you can go to my homepage to ask me):
<% @LANGUAGE = VBScript%>
<%
Response.Write "<HTML><BODY>" equals output statements in programming languages
Response.Write "Output to the browser."
Response.Write "</BODY></HTML>"
%>
After editing, place the wuf1.asp under the home directory "\inetpub\wwwroot" where the default Web site is installed, and enter http://localhost/wuf1.asp in the browser to see the output. Let's look at one more example (wuf2.asp):
<body>
IP address = <%=request.servervariables ("remote_addr")%>
</body>
The output result is the native IP address, simple. In the above two examples, we use Notepad as the editor (because the ASP file is a text file), but if you really want to use ASP, I recommend the following tools:
1. HomeSite: Not only is one of the best tools to make the homepage, writing ASP files is also very good.
2. Asp-edit Professional: Not only can display ASP code in different colors, there are ASP courses and VBScript Help, these two files can go to the Chinese Army homepage (http://www.newhua.com) download.
3. Microsoft Visual InterDev6.0: Although it is a sledgehammer, but it is the best tool to edit ASP files, if you have used VB, its advantages will not need to say more.
It should be explained that the current popular DreamWeaver3.0 for the home page is good, but it is best not to edit the file with ASP code, so as to avoid the confusion.

Iii. Understanding ASP Scripting Environment
ASP (Active server Pages) is a powerful, flexible and easy to learn server-side scripting environment, its source code is running on the server side, the results of the operation in the form of HTML code output to the client. ASP can not only quickly create interactive dynamic Web pages, and the program code is completely confidential, more importantly, regardless of the client user to use which browser, can be applied to various browsers. If you are using client-side scripting (such as VBScript or JavaScript), you should consider the browser the user is using. We can do this to understand the ASP program:
1. As can be seen from the above two examples, ASP file extension is. asp, an ASP file usually consists of ASP script commands and HTML tags, text composition, ASP commands must be surrounded by "<%%>" (about <% @LANGUAGE = VBScript%> Don't be in a hurry to figure it out and talk about it later.
2. Beginners to understand the ASP program, as long as the split can (must not stir together, confusedly). Note that after you remove the code enclosed by <%%>, you can read the same as the. htm file you used. And when the <%%> is running on the server side, the resulting output is the HTML code you're familiar with. If Response.Write "<HTML><BODY>" Get is <body>
IP address = 16.62.5.60
</body>
You can deepen your understanding by selecting "Source Files" under the "View" menu in IE.

Iv. Foundation of Maito--asp
1. Outputs the result (string information) to the browser, which is the syntax: the content displayed by Response.Write. As you can see from the example wuf2.asp, you can use "<%= content%>" instead of "<%response.write display%>".
2. Using variables, wuf2.asp can be changed to:
<% @LANGUAGE = VBScript%>
<% ' single quotation mark after comment –wuf3.asp
Option Explicit ' requires variable declaration, use it to reduce the possibility of error in the program, improve efficiency
Dim ipaddr ' It's best to declare before using a variable
IPAddr = Request.ServerVariables ("REMOTE_ADDR")
%>
<body>
IP address = <%=IPaddr%>
</body>
3. To use a function in a program:
<%@ Language=vbscript%>
<%response.expires = 0%>
<HTML>
<HEAD>
<title> Use Functions-wuf4.asp</title>
</HEAD>
<BODY>
<P> today's date: <% = date%></p>
<P> Present time: <% = time%></p>
<P> present time: <font color= "#CC0033" ><% = time%></font></p>
<%response.write "<P> now: <font color= ' #CC0033 ' >" & Time & "</font></P>"%>
</BODY>
</HTML>
In the example above, the & "equals" + ", date and time are functions (note: This is a Web server time, not the time of the browser's machine, from which you can verify that ASP commands are executed on the server side), ASP, and many other functions, This article is impossible to enumerate, please consult yourself.
As for <%response.expires = 0%&gt, we know that browsers can cache Web pages to speed access, while Response.Expires is the time to set the page to remain in the client browser cache (minutes). If set to 0, the Web page data is not kept in the client's cache. It must be placed before the <HTML> label. Specifically to this example, if you do not have this setting, you only press the "Refresh" button, the time will be updated, and only in the address bar to hit enter, time is not change, and add this sentence set, every time you hit the return, times will be updated once.
4. To use a conditional statement:
<%@ Language=vbscript%>
<% ' wuf5.asp
If time<= #12:00:00# Then
Response.Redirect "Wuf1.asp"
ElseIf time<= #18:00:00# Then
Response.Redirect "Wuf2.asp"
Else
Response.Redirect "Wuf3.asp"
End If
%>
Date with # #引起来, Response.Redirect is responsible for booting the client browser to display the new page, which is usually said to redirect, remember that this feature is very useful.
5. To use a looping statement:
<%@ Language=vbscript%>
<%option explicit%>
<HTML>
<BODY>
<%
Dim I
While I<=5
Response.Write "<P>" & "There are other cyclic structures, such as do ... Loop while, "&_
"Do-while ... Loop, for ... Next,for Each ... Next etc "&" </P> "
I=i+1
Wend
%>
</BODY>
</HTML>
From the example above, you should pay attention to how to use "_" to wrap the line.
6. Use include file. For a Web site, where the top or bottom of each page is basically the same, you can put the same part in a file and then reference it as needed. First, edit a file named comm.asp as follows:
<style type= "Text/css" >
<!--
Font {font-family: "Song Body", "Times New Roman"; font-size:9pt}
-->
</style>
<body>
<table width= "640" border= "0" bordercolor= "#9999FF" bgcolor= "#FFFFFF" bordercolorlight= "#3333FF" bordercolordark= "#CC0000" >
<tr bgcolor= "#006666" bordercolor= "#009933" >
&LT;TD align= "center" height= "colspan=" 2 "><font color=" #FFFFFF ">⊙
"丰子 Homeland" copyright-</font><font color= "#FFFF00" > Station in March 1997 </font>
</td> </tr>
</table>
</body>
Edit the following files again:
<% @LANGUAGE = VBScript%>
<HTML>
<BODY>
<% ' wuf7.asp
Response.Write "Output to the browser."
%>
<!--#include file= "comm.asp"-->
</BODY>
</HTML>
Include file can be placed anywhere on the Web page, but must be positioned outside of all ASP code blocks.
In addition, there are processes, functions, parameters, such as the concept of transmission, if you have not been contacted before, or first put the best, first from the overall understanding of ASP, and then gradually refined



Related Article

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.