This article will focus on how to build an iis-based asp dynamic website to reveal the real secrets of dynamic business website design step by step.In order to enable you to fully and meticulously develop ASP development skills,This article will take the form of serialization in the future,Teach you how to build your own asp dynamic website.Because this article was written by the author based on his own learning and practical experience and combined with some foreign materials,So there can be some bias.I hope you all forgive me.

Microsoft active server pages is what we call asp, which is actually a server-side scripting environment developed by Microsoft. ASP is included in IIS 3.0 and 4.0. Through ASP we can combine html web pages, ASP commands and activex components to build dynamic, interactive and efficient web server applications.With asp you don't have to worry about whether your client's browser can run the code you write,Because all programs will be executed on the server side,Includes all script programs embedded in normal html.When the program finishes executing,The server only returns the results of the execution to the client browser,This also reduces the burden on the client browser,Greatly improved the speed of interaction.

Here are some of the unique features of active server pages:

1. Use easy-to-understand scripting languages ​​such as vbscript, jscript, etc.Combined with html code, you can quickly complete a website application.

2. No need to compile, easy to write,Can be executed directly on the server.

3. Use a normal text editor,Like notepad for windows,You can edit the design.

4. Browser independence, as long as the client uses a browser that can execute html code,You can browse the web content designed by active server pages. The scripting languages ​​(vbscript, jscript) used by active server pages are all executed on the web server.The client browser does not need to be able to execute these scripting languages.

5. Active server pages are compatible with any activex scripting language.In addition to being designed using vbscript or jscript languages,Also through plug-in, using other scripting languages ​​provided by third parties,For example, rexx, perl, tcl, etc. The script engine is a com (component object model) object that processes script programs.

Source program for 6.active server pages,Will not be passed to the client ’s browser,So you can avoid the source code being plagiarized by others,It also improves program security.

7. Server-side scripts can be used to generate client-side scripts.

8. Object-oriented.

9. activex server components have infinite scalability.You can use visual basic, java, visual c++, cobol and other programming languages ​​to write the activex server component you need.

The wonders of asp are endless.Now, please fasten your seat belts.I will lead you into the dream world of asp. First, let ’s take a look atEnvironment 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 normal procedures,.asp programs do not need to be compiled,control part of asp program,It is designed using scripting languages ​​such as vbscript, jscript, etc.When the asp program is executed, the script program sends a complete set of commands to the script interpreter (that is, the script engine), which is translated by the script interpreter and converted into commands that the server can execute.Of course, like other programming languages, Asp programming also follows certain rules,If i want to write ASP programs in your favorite scripting language, you must have a script interpreter on your server that can interpret this scripting language.

When you install asp, two scripting languages ​​are provided:vbsrcipt and jscript, and vbscript is used as the system's default scripting language.You can also change the default scripting language of the system according to your preferences.For how to change the system's default scripting language, see the article "Using scripting languages ​​in ASP." asp itself is not a scripting language,It just provides an environment for script programs embedded in html pages to run.However, to learn ASP well, you must master its syntax and rules.Now let's get to know and learn active server pages step by step.

The asp program actually exists on the web server in plain text with the extension .asp,You can open it with any text editor, asp programs can contain plain text, html tags, and script commands.You only need to put the .asp program in the virtual directory of the web server (the directory must have executable permissions), and then you can access the asp program through www.

To learn the design of asp program,Must master script writing,So what exactly is a script?In fact, the script is composed of a series of script commands.As usual,The script can assign a value to a variable,You can instruct the web server to send a value to the client browser,You can also define a series of commands as a procedure.To write a script,You must be familiar with at least one scripting language,Such as vbscript.

Scripting language is a special language between html and programming languages ​​such as java, visual basic, c++, etc.Although it is closer to the latter,But it does not have the complex and rigorous syntax and rules of a programming language.As mentioned earlier, the script runtime environment provided by asp can support multiple scripting languages,For example:jscript, rexx, perl, etc. This will undoubtedly provide a wide range of room for asp programmers.

The emergence of asp frees web designers from worrying about whether their browsers support it.In fact, even if you use different scripting languages ​​in the same .asp file,You do n’t need to worry about it,Because everything will happen on the server side,The client browser only gets the result of a program execution,And you just need to declare a different scripting language in .asp.

Here is a typical example of using two scripting languages ​​in the same .asp file:

<%call callme%>
<%call viewdate%>
<script language=vbscript runat=server>
sub callme
response.write "<tr><td>call</td><td>me</td></tr>"
end sub
<script language=jscript runat=server>
function viewdate ()
{var x x=new date ()
response.write (x.tostring ())}

This is the first real asp program you have come across in this article. Don't get confused by the "<%%>" symbol,This is actually the standard asp delimiter, and the script language is between "<script></script>".

asp is different from scripting language,It has its own specific syntax,All asp commands must be enclosed in<%and%>such as:

<%test="english"%> ;, asp outputs the execution result to the client browser through expressions contained in<%and%> ;, such as:<%= test%>The value of the variable test is sent to the client browser.When the value of the variable test is mathematics, the following program:this weekend we will test<%= test%> ;. In the client browser, it displays:this weekend we will test mathematics.

The best way to learn asp is to write it yourself,In order to let you master the programming skills of ASP in the shortest time,This article will take a case analysis method,Through a series of examples, let you learn asp in practice.

To build an ASP page, all you need is to open a text editor,Such as:notepad, and then I started to write the first asp program. Below we will build an asp program that automatically monitors browsing time and dynamically displays different page content according to different time periods. Please cut and paste the following code into your text editor and save it astest1.asp:

<font color="green">
<%if time<#12:00:00 #and time>= #00:00:00 #then%>
Good morning, the weather is not bad today!
<%elseif time<#19:00:00 #and time>= #12:00:00 #then%>
good afternoon !
Hello! Did you go to irc tonight to chat!
<%end if%>

Save test1.asp in the virtual directory of the web server (such as:aspsamp /), and browse it with http in the browser.Such as:http://yourcomputername/aspsamp/test1.asp, you will find it strangely,Your page is really alive.Although this is just a very simple example,And this function can be completed by javascript, but it is not difficult to find that using asp is much simpler and faster than javascript.And using this method,You can easily make your web page display different styles at different times.

The time in this example is actually a vbscript built-in function that displays the current time of the system.Because the system's default scripting language is vbscript, when you call the function in the asp command,The script engine will automatically convert it to the current system time.

Next we will add a little color to test1.asp,Adding "bgcolor ="<%= bgc%>"to thetag becomes= #00:00:00 #then bgc="silver" elseif time<#19:00:00 #and time>;= #12:00:00 #then bgc="navy" else bgc="red" end if%>When users visit your page at different times,They will see different page background colors.

There is much more we can do,Let ’s say i want to know the name of the customer who visited your page between midnight and twelve.And say hello to him or her,Then the following procedure will help you achieve your wish.First you need to set up the form in the page,Paste the following html code after "<%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>first name:<input name="fname" size="48">
<p>last name:<input name="lname" size="48">
<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>

Then add the following asp command after the above html code:

<%title=request.form ("title") if then%>
Welcome mr.<%= request.form ("fname")%>.
<%elseif then%>
Welcome ms.<%= request.form ("fname")%>.
<b><font color=blue>Welcome<%= request.form ("fname")&""&request.form ("lname")%>.</font></b>
<%end if%>

Save the file test1.asp and browse it with http in your browser.If the system time at this time is between 0:00:00 and 12:00:00 noon,The browser will display the following screen:

This is actually a common feature on the internet and intranet.That is, when the user completes the form on the browser,User data is transferred to the server by calling a common gateway program,After processing by the server, the results are returned to the client browser.In the past, in order to achieve such a function, a cgi program independent of html must be written and called through html.Leaving aside the disadvantages of cgi writing complexity, cgi's execution efficiency is also a big problem,Each form must execute an executable document,When multiple people are online at the same time,Multiple documents execute at the same time,Will greatly reduce the execution speed of the web server,Asp now provides a programming environment that is fully integrated with html,Obviously more convenient than using cgi.

At the end of this issue, let's take a look at the loop function of asp.For example, if i want your customers to visit your page between 7:00 PM and 0:00:00 AM,6 smiley greetings in the center of the page,Then you just need to cut and paste the following command after "good evening!":

<%for i=1 to 6%>
<p><center><img src="smile.gif" width="32" height="32"></p>

This is the most basic loop statement.It calls a smiley picture six times and displays it on the page.Of course, the effect of this example can be achieved with html, but it is not difficult to find that using asp greatly shortens the re-writing of the code,Make the program readable.

In addition, when you make a review site, such as rating stars based on user votes,Using this method,You don't need to make a picture for every star at all.If an object is rated 4 stars, you only need to cycle through the pictures of a star 4 times, and so on.

  • Previous Getting started with python3 crawlers and regular expressions
  • Next Introduction to ASP Basics Part 2 (ASP Basics)