Introduction to Active Server Pages

xiaoxiao2021-03-06  96

Discussion

ASP is a set of software components that run on a Web server and allow Web developers to build dynamic Web pages. The advantage of ASP over static HTML Web pages is that an ASP page is like a computer program that runs on a Web server and can .

Related Technologies

ASP runs with a Web server on the Microsoft Windows platform. The Web server that is used is Internet Information Server (IIS). It is also possible to run ASP with a limited feature set on Microsoft Personal Web Server (PWS), which runs on Microsoft Windows 95, Microsoft Windows 98, And Microsoft Windows NT Workstation. ASP Can Also Run on UNIX Operating Systems By Using Special Extensions That Are Created by Software Vendors.

Because ASP is frequently used to create business applications on the Web, it is regularly used with databases such as Microsoft Access, Microsoft SQL Server, or databases from other vendors. When used in conjunction with a database, ASP pages can even run transactional applications, such as those used by banks, by using the features of COM or Microsoft Transaction Server (MTS). A number of tools can be used to create ASP pages, ranging from simple text editors such as Notepad, popular Web site creation tools by Microsoft and Other Vendors, OR A Full-Featured Programming Tool Such AS Microsoft Visual InterDev.

Running ASP

ASP version 3.0 is included with all versions of the Microsoft Windows 2000 operating system. ASP is installed automatically when you install the Internet Information Services option with Windows 2000. The older version of ASP, version 2.0, runs on Microsoft Windows NT 4.0 Server, which requires you to install the Windows NT 4.0 Option Pack. ASP version 2.0 also runs on Windows 95, Windows 98, and Windows NT 4.0 Workstation by installing Personal Web Server (PWS). PWS is included with the Windows NT Option Pack. However, ASP is not supported on Windows Millennium Edition.Please Note:. due to DotNetNuke Text Editor problems with the less than and greater than characters, these have been replaced in this article with "[]" brackets If you copy and paste the markup in this article You'll Need to Replace The "[]" Brackets with the corresponding greater trion "" "

CREANG YOUR FIRST ASP Page

For this example, do not use Visual InterDev or FrontPage to create an ASP page. Although both applications can create ASP pages easily, it is better for learning purposes to hand-code the ASP page in a simple text editor such as Notepad.

In Notepad, Paste The Following Code for the Basic Page Structure:

[% @ Language = "vbscript"%]

[html]

[head]

[meta http-equiv = "content-type" content = "text / html; charSet = windows-1252"]

[Title] My First ASP Page [/ Title]

[/ hEAD]

[body]

[/ body]

[/ html]

Type some ASP identifier tags and ASP code in the page. Note that for ASP code to run, it must be identified by one of the following sets of tags. The Web server uses these tags to identify the code that must be processed on the server Before It Returns the page to a browser. ASP Identifier Tag 1: [Your Asp Code Goes Here]%]%]%]%]%]%]%

In this approach, you create an opening tag with the less, a closing tag with the percent (%) And greater tour you (]) Symbols, and you write your asp code betWeen the Opening and Closing tags. ASP Identifier Tag 2:

[Script runat = "server"]

[Your ASP Code Goes Here]

[/ Script]

In this approach, the script tags are the same as the HTML script tags, except that the opening script tag has an attribute called runat = 'Server'. As an example, put a pair of ASP tags between the body tags in your ASP page Between The Asp Tags, Input The Following Vbscript Code Sample So That The Completed Version of Your ASP Page Rembletes The Following:

[% @ Language = "vbscript"%]

[html]

[head]

[meta http-equiv = "content-type" content = "text / html; charSet = windows-1252"]

[Title] My First ASP Page [/ Title]

[/ hEAD]

[body]

[%

'Use an apostrophe to delimit code comment lines like this one.

'Declare Variables.

DIM STRGREETING, STRTIME, STRTOTAL

'Process and colevate.

STRTOTAL = 10 * 21

Strtime = now ()

'Create a String That Inserts the value of the two yrier

'variables.

Strgreeting = "Hello World! The Current Date and Time Are:" & _

STRTIME & _

"[BR]" & "The Result of Our Calculation IS:" & _

Strtotal

'Output the results to the browserresponse.write strgreeting

%]

[/ body]

[/ html]

Save the ASP Page to the Web Server

Now save your ASP page to the Windows folder that is created for your Web application in step 1. When you used the Server Extensions Web Wizard in step 1, you typed a folder name for the physical Windows folder that contains your Web application's content, and then the wizard created the folder for you. By default, the wizard creates the new folder and subweb in the root site for IIS. Because you used the name MyWeb for your folder and your title alias, the typical path to it on your system resembles The Following:

C: / inetpub / wwwroot / myWeb

When the MyWeb application is running under IIS, and you use a Web browser to view the application, the URL path for the application starts with the Web protocol. (Http: //) Next, if this is a local Web that is only on your computer or on your company intranet, use your Windows computer name (for example, MyServer), or for publicly accessible Internet sites, use your domain name (for example, www.MyCompany.com). Finally, append the alias or title of Your Web Application's Subfolder. The Resulting Url Resembles The Following URL:

http:// myserver / myweb

-or-

http://www.mycompany.com/myweb

To Save The ASP Page That You Created In The Previous Step and Put IN Your Web Application, FOLLOW THESE STEPS:

. In Notepad, on the File menu, click Save In the Save As dialog box, use the Save In drop-down list box to locate your application's physical folder (for example, C: / Inetpub / Wwwroot / MyWeb). In the Save as type drop-down list box, select All Files. In the File name text box, delete any default file extensions that you see, and then type your file name with the ASP extension (for example, Default.asp). Click Save. Use the Web Server to view the page

Open a Web browser, such as Microsoft Internet Explorer. In the address line, type the URL to your new ASP page. For example, if your server is running locally (that is, it is not serving pages on the Internet), the URL Resembles The Following:

http://mycomputername/myweb/default.asp

OR, IF Your Server IS Serving Pages on The Internet, The Url Resembles The Following:

http://www.mycompany.com/myweb/default.asp

Note that new Web applications in IIS are automatically set to use either Default or Index as a default file in the virtual folder for your Web application. In other words, if you use Default.asp as the name for your home page or the first page In Your Application, you do not have to use the file name in the url. You can Just Locate The Virtual Folder That Contains The Default.asp page, As Follows:

http:// mycomputername / myWeb /

转载请注明原文地址:https://www.9cbs.com/read-123289.html

New Post(0)