ASP basic Lectures (on)

Source: Internet
Author: User
Tags object end html form interface return domain name access
You "Fever nets worm", you are racking your brains to improve their own web page? Are you trying to get a CGI program in mind? See other people using foxweb technology to develop the data application system based on WWW, do you already covet? Don't panic, we will provide you with the forefront of the dynamic Web technology. Today for everyone please come to Intranet&asp site responsible LWW (authentic Chinese yo) for everyone to first an ASP basic courses, including the most basic interactive interface design and the most concerned about the database access technology, take a look at it.
Active Server Pages (ASP, Dynamic Web pages) is a technology introduced by Microsoft to replace CGI (Universal Gateway Interface, Common gateways Interface). Microsoft released Win98, also launched the PWS4.0 (Personal Web server, can be found in the Win98 CD add-ons directory), which itself supports the interpretation of the implementation of ASP2.0, so we do not have to find a free server can experience the simplicity and convenience of ASP.
Simply speaking, ASP is a server-side scripting environment in which users can create and run dynamic interactive Web server applications, such as interactive dynamic Web pages, including the use of HTML forms to collect and process information, upload and download, and so on, just as users use their own CGI programs. But he's simpler than CGI. More importantly, the ActiveX technology used by ASP is based on an open design environment in which users can define and make components to join and make their dynamic web pages almost limitless, which is far less than traditional CGI programs. The advantage of using ASP is that the ASP can access the database easily using ADO (Active data Object, a new Microsoft Data access model, similar to DAO), making it possible to develop a WWW based application system.
How do I use ASP?
Let's take an example to illustrate it. I've seen many language-speaking books as the first example of "Hello world", so let's ask the rest of us.
First step: Open a text editor (for example, Notepad) and enter the following code:
<% for i=3 to 7%>
<font size=<%=i%>>
Hello world!<br>
<% Next%>
Then save it as a filename hello.asp. Because. asp files are interpreted by the server-side ASP environment,
The second step: you must put it in the WWW server directory. In the Win98 system where PWS is installed, the default path is C:wroot, and you can also build a subdirectory of your own, such as "ASP".
Step three: Open the browser, enter the http://yourservername/asp/Hello.asp, the browser immediately show "Hello World", it is so simple.
Now, let's go back and analyze the script above, you will find that compared with the HTML script, it has more than two symbols <% and%> this is the ASP's delimiter, he separates the general HTML script from the ASP code, the middle code is the ASP "language", we must have seen, His grammar is similar to that of Visual Basic. The scripting language of an ASP can be any script language, but you have to provide the appropriate engine. The ASP itself supports VBScript and JavaScript, and it's up to you to decide which one to use. You just need to use a <script language= "VBScript" runat= "Server" > or <scriptlanguage= "JavaScript" runat= "Server" before using ASP scripts > on the line. The default language is VBScript, Microsoft's.
So what is the process of implementing an ASP? When you enter the address of the. asp file from the browser, the browser sends the URL request to the server, and if the server has ASP, he will call ASP if he sees an. asp suffix name. The ASP reads the corresponding. asp file, interprets and executes the command, passes the results back to the WWW server, and then the WWW server sends the results to the browser. The browser sees the execution result, and he has no idea. asp file is going on, so using ASP does not have to consider browser differences.
User submits ASP file process
Let ASP work with form
We say that the purpose of ASP is to allow users to exchange information between the page, then, how to get the user input this information? Of course, it's a form. Whether it's CGI, IDC, JAVA, or any other technology, it is through the form embedded in the WWW page that allows the browser's users to enter information, then the form executes the submit action, passes the data to the server, and the server passes the data to the CGI or other program. Now that the form is so important, let's take a look at how to get the data that the user entered in form in the ASP, and we'll also learn how the ASP returns the results to the WWW page.
First, we create a form with his HTML code as follows:
<HEAD><TITLE> orders </TITLE></HEAD>
<BODY>
<H2> Order Form Example </H2>
<P> Please provide us with the following information, and then click Submit:
<form method= "POST" action= "response.asp" >
<P> Surname: <input name= "fname" size= "a" >
<P> Name: <input name= "lname" size= "a" >
<P> Address: <input name= "title" Type=radio value= "Mr." > Mr.
<input name= "title" Type=radio value= "Ms." >
<p><input type=submit value= "Submit" ><input Type=reset value= "Clear" >
</FORM>
</BODY>
This form is a simple example of an order that receives a user's name, salutation, and then submits the data using the Post method. We know that there are often two ways to submit data in HTML form (form), one is get, the other is post. For data submitted by GET, the WWW server places the data in the environment variable query_string, and for the Post method, the data is sent to the stdout of the WWW server, and then the CGI reads from its own stdin. Using the traditional CGI method, users must programmatically process the data themselves. However, in the ASP, the object-oriented thinking, all data from the browser is encapsulated in the object request. The request has method form and querystring that return data submitted using the Post method and the Get method, respectively. To get the data submitted by the form, simply use Request.Form ("form domain name") or Request.QueryString ("Query parameter name").
OK, then let's set up the. asp file response.asp to process the data submitted by the form above, we simply return the data submitted by the user to the user.
<%title=request.form ("Title")
Lastname=request.form ("lname")
If title= "Mr." Then%>
Mr. <%=lastname%>
<% ElseIf title= "Lady" Then%>
Ms. <%= LastName%>
<% Else &>
<%=request.form ("FName") & "" & LastName%>
<% End If%>
The code above is a little hard to understand. Let's analyze it. First, his beginning and end are no different from the ordinary HTML code, the key is the middle. If you omit the delimiter <% and%&gt, and then add ' Print ' to the previous sign without something, it becomes:
Title=request.form ("title")
Lastname=request.form ("lname")
If title= "Mr." Then
Print Mr. LastName
ElseIf title= "Lady" Then
Ms. Print LastName
Else
Print Request.Form ("FName") & "" & LastName
End If
Is this VB? Is it simple? ASP is the application of this method, the user wrote the program to link into the HTML, so that dynamic Web pages can be realized.
One thing to note is that. asp files are not

[1] [2] Next page



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.