This article will be on how to build an ASP Dynamic Web site based on IIS as the center to everyone step-by-step to reveal the real secret of dynamic commercial website design. In order to enable you to fully and carefully grasp the development of ASP skills, this article will take the form of serialization, hands-on teaching you how to build your own ASP Dynamic Web site. Because this article is the author according to own study and the practical experience and unifies some foreign language material to write, therefore unavoidably may have some biased, hoped that everybody forgive me.
Microsoft Active Server Pages, what we call ASP, is actually a set of Microsoft-developed server-side scripting environments, which are embedded in IIS 3.0 and 4.0, with ASP we can combine HTML pages, ASP directives, and ACT Ivex components to create dynamic, interactive, and efficient WEB server applications. With ASP you don't have to worry about whether the client's browser will be able to run the code you write, because all programs will be executed on the server side, including all the scripting programs embedded in normal HTML. When the program is finished, the server only returns the results of the execution to the client browser, which reduces the burden on the client browser and greatly increases the speed of the interaction.
lists some of the features unique to Active Server Pages:
1. Use simple scripting languages such as VBScript, JScript, and HTML code to quickly complete your Web site's applications.
2. No compile compile, easy to write, can be directly executed on the server side.
3. Use a normal text editor, such as a notepad for Windows, for editing and design.
4. Browser-Independent (Browser independence), the client can browse the content of Web pages that are designed by Active Server pages as long as they use an executable HTML code browser. The scripting language (VBScript, Jscript) used by Active server Pages is executed on the WEB server side, and the client's browser does not need to be able to execute these scripting languages.
5.Active Server Pages can be compatible with any ActiveX scripting language. In addition to being designed using VBScript or JScript languages, other scripting languages provided by third parties, such as REXX, Perl, TCL, are used in plug-in. The scripting engine is a COM (Component object Model) object that handles a script program.
6.Active Server Pages of the source program, will not be uploaded to the client browser, so you can avoid the written source program by others plagiarism, but also improve the security of the program.
7. You can use server-side scripts to generate client script.
8. Object Oriented (object-oriented).
9.ActiveX Server components (ActiveX server component) has unlimited scalability. You can use the programming languages of Visual Basic, Java, Visual C + +, COBOL to write the ActiveX Server Component you need.
The wonders of the ASP are countless, below please fasten your seatbelt, I will lead you into the dream world of ASP. First, let's look at the environments that are required to run ASP:
· Microsoft Internet Information Server version 3.0/4.0 on Windows NT server Microsoft Peer Web Services Version 3.0 on Windows NT Workstation
· Microsoft Personal Web Server on Windows 95/98
Unlike general procedures,. ASP programs do not need to compile, the control part of the ASP program, is used in VBScript, JScript and other scripting languages to design, when the implementation of ASP program, the script will send a complete set of commands to the script interpreter (that is, script engine), Translated by the script interpreter and converted to a command that the server can execute. Of course, as with other programming languages, ASP program writing also follow certain rules, if you want to use your favorite scripting language to write ASP program, then your server must have the ability to interpret this scripting language script interpreter.
When you install ASP, the system provides two scripting languages: Vbsrcipt and JScript, while VBscript is the default scripting language for the system. You can also change the default scripting language of your system according to your preferences, see the scripting language in ASP. The ASP itself is not a scripting language, it simply provides an environment in which scripting programs embedded in HTML pages can run. However, to learn the ASP and must master its grammar and rules. Now let's start with a step-by-step understanding and learning about Active Server Pages.
The ASP program actually exists on the WEB server in plain text format with the extension. asp, you can open it with any text editor, and the ASP program can contain plain text, HTML tags, and script commands. You simply place the. asp program in the WEB server's virtual directory (the directory must have executable permissions), you can access the ASP program via WWW.
To learn the design of ASP program, must master the script writing, then what is the script? In fact, the script is composed of a series of script commands, like a normal program, the script can assign a value to a variable, you can command the Web server to send a value to the client browser, you can also define a series of commands as a process. To write a script, you have to be familiar with at least one scripting language, such as VBScript.
A scripting language is a special language between HTML and programming languages such as JAVA, Visual Basic, and C + +, and although it is closer to the latter, it does not have complex, rigorous syntax and rules for programming languages. The scripting environments provided by ASP, as described earlier, can support multiple scripting languages, such as JScript, REXX, PERL, and so on, which undoubtedly provide an extensive scope for ASP programmers.
The advent of ASP has made it unnecessary for the vast majority of WEB designers to worry about whether or not to support customer browsers in fact, even if you're using a different scripting language in the same. asp file, you don't have to worry about it because everything is going to be done on the server side, and the client browser gets just the result of a program execution, And you just have to declare in. asp that you can use a different scripting language.
The following is a typical example of using two scripting languages in the same. asp file:
< html>
< body>
< table>
<% call Callme%>
</table>
<% call Viewd Ate%>
</body>
This is your first contact in this article of the real ASP program, do not be "<%%>" symbol confused, this is actually the standard ASP delimiter, and "< script></script>" between the scripting language.
Unlike scripting languages, ASP has its own specific syntax, and all ASP commands must be contained within <% and%>, such as:
<% test= "中文版"%>, ASP outputs execution results to the customer browser via an expression contained in <% and%>, such as <% =test%> is the value assigned to the variable test before Englis H is sent to the client browser, and when the value of the variable test is mathematics, the following program: This weekend we'll test <% =test%>. In the client browser, it appears as: this weekend we'll test mathematics.
The best way to learn ASP is to write in person, in order to enable you in the shortest possible time to master the design skills of ASP, this article will take the example analysis, through a series of examples to let you learn in practice ASP.
To create an ASP page, all you need to do is open a text editor, such as Notepad, and then start writing the first ASP program with me. Below we will establish an automatic monitoring browsing time and dynamically display different page content according to different period of ASP program, please clip the following code into your text editor, coexist for test1.asp:
< html>
< body>
< FONT color= "Green" >
<% If Time < #12:00:00# and time> = #00:00:0 0# Then%>
Good morning, the weather is not bad today!
<% ElseIf Time < #19:00:00# and Time >= #12:00:00# Then%>
Good afternoon!
<% Else%>
ha! Did you go to IRC for a chat tonight?
<% end If%>
</body>
Save Test1.asp to the WEB server's virtual directory (such as: aspsamp/) and browse in the browser using HTTP, such as: http://yourcomputername/aspsamp/test1.asp, you will find novelty, Your page is really alive. Although this is a very simple example, and this functionality can be done through JavaScript, it is easy to find that using ASP is much simpler and faster than JavaScript, and by using this method, you can easily make your pages show different styles at different times.
The time in this example is actually a function in VBScript that displays the system's current times, because the system default scripting language is VBScript, so when you call the function in an ASP command, the script engine automatically converts it to the current system time.
Next we will add a bit of color to test1.asp, add "bgcolor=" <% =BGC%> to the < body> logo "that becomes < body bgcolor=" <% =BGC%> "> and add the following statement before the < body> tag: <% If Time < #12:00:00# and Time >= #00:00:00# Then bgc= "Silver" ElseIf Time < # 19:00:00# and Time >= #12:00:00# Then bgc= ' Navy ' Else bgc= ' red ' End if%> so, when users visit your page at different times, they will see a different background color of the page.
There are many things we can do, such as you want to know the name of the customer browsing your page between midnight and 12, and say hello to him or her, and the following procedure will help you achieve your wish. First you need to set up the form in the page and paste the following HTML code into "<% If Time < #12:00:00# and Time >= #00:00:00# Then%>":
Welcome to my homepage, please fill in the following information:
< FORM method= "POST" action= "test1.asp" >
< p>-Name: < INPUT name= "fname" size= "the" >
< P> last Name: < INPUT name= "lname" size= "a" >
< p> title: < INPUT name= "title" Type=radio value= "Mr" > Mr.
< input name= "title" Type=radio value= "MS" >ms.
< p>< input type=submit>< input Type=reset>
</form>
Then add the following ASP command after the HTML code above:
<% title=request.form ("title") If title= "Mr" then%>
welcome you mr.<% =request.form ("fname")%>.
<% ElseIf title= "MS" then%>
welcome you ms.<% =request.form ("fname")%>.
<% Else%>
< b>< font color=blue> welcome you <% =request.form ("fname") & "" &request.for M ("lname")%>. </font></b>
<% End If%>
Save the file test1.asp and browse HTTP in the browser, if the system time between 0:00:00 and 12:00:00, the browser will display the following screen:
This is actually a common feature on the Internet and on the Intranet, when users fill out a form on the browser side, and then send the user data to the server by calling a common Gateway program, which is processed by the server and then returned to the client browser. In the past, it was necessary to write a CGI program that was independent of HTML in order to implement such a function, and the use of HTML to invoke, aside from the CGI complex and other shortcomings do not talk about the efficiency of CGI is also a big problem, each form (form) must execute an executable document, when more than one person on-line use, The simultaneous execution of multiple documents will significantly reduce the speed at which the WEB server executes, and today the ASP provides a completely integrated programming environment that is obviously much easier to use than CGI.
At the end of this issue, let's take a look at the cyclic functionality of the ASP, for example, if you want to display 6 smiley greetings in the middle of the page when the customer browses your page from 7:00 to 0:00:00, you only need to clip the following command to the good evening! "later:
<% for I=1 to 6%>
< p>< center>< img src= "smile.gif" width= "" "height=" alt= "Good Evening" >< /p>
<% next%>
This is the most basic loop statement that repeats a smiley face image six times and is displayed on the page. Of course, the effect of this example can be done with HTML, but it is not difficult to find that the use of ASP greatly shorten the code of repeated writing, so that the program has good readability.
In addition, when you make a rating site that evaluates a star based on a user's vote, you don't have to make a picture for each star at all. If an object is rated as 4 stars, then you just need to loop the picture of one star 4 times, and so on.
The above is the entire content of this article, I hope that you learn the ASP programming help.