Introduction to ASP


Quite possibly the simplest technology to use in conjunction with Dreamweaver dynamic Web page development is ASP. ASP, or Active Server Pages, is a Microsoft-developed web-scripting language that took the web development world by storm when it was introduced in the mid 1990s. ASP is easy to understand and easy to useand setup is a breeze because the required files are pre-installed on virtually all Windows servers.

Like many other server-side technologies, ASP enables you to embed special instructions in HTML pages that can do a variety of tasks, such as connect to a database, perform looping instructions, conditionally test for certain values, send emails, read from and write to the file system, and more. Because ASP runs natively on Microsoft's IIS web server, installing ASP generally means installing IIS. If IIS is up and running, chances are, so is ASP. It's no wonder that the majority of users who create dynamic web pages in Dreamweaver still use traditional ASP as their server-side technology of choice; if you have IIS installed (which most people who are building dynamic web pages do) then there's little to no setup and nothing to install.

Creating a Simple ASP Page

Now that you've had a formal introduction to ASP, let's walk through the process of creating a simple ASP page. Not only will this process help familiarize you with the technology, but you'll also get a deep understanding of how IIS handles the processing of a dynamic ASP page. To create a simple ASP page, follow these steps:

1.

Create a new folder in C:\Inetpub\wwwroot called DorknozzleASP.

2.

Open Notepad (we'll get to Dreamweaver later).

3.

In the document, add the following code:

 <html> <head> <title>Sample ASP Page</title> </head> <body> <h1>This is plain text</h1> <h1><%= "This is ASP writing text to the browser dynamically" %></h1> </body> </html> 

4.

Save your work as sample.asp in the new folder named C:\Inetpub\wwwroot\DorknozzleASP.

TIP

If you plan on trying out numerous server-side technologies, it's beneficial to create the folder with the Dorknozzle name followed by the three-letter server-side technology you plan to use. This convention prevents you from continuously having to redefine the site for every server-side technology.


To test your work, open the browser and type the http://localhost/DorknozzleASP/sample.asp URL in the address bar. As you can see from Figure 22.4, two lines of text appear in the browser.

Figure 22.4. Two lines of text appear in the browser.


Although this result may not seem all that awe inspiring, think again: You've just created your first dynamic web page using ASP. Look at the code again and see if you can pick apart the dynamic portions of the page. For the most part, 8 of the 9 lines in the page are plain old HTML that IIS does nothing with. It simply lets the browser parse the HTML tags and presents to the user the text inside them. Line 7, however, works a bit differently:

 <h1><%= "This is ASP writing text to the browser dynamically" %></h1> 

In this case, we use what's called a code render block to dynamically display the text This is ASP writing text to the browser dynamically within a <h1> HTML tag. IIS, recognizing that this code render block exists, intercepts the request and calls for help from the asp.dll located in the C:\Windows\system32\inetsrv folder. The asp.dll processes the request and takes the code render block to mean "Print out the text This is ASP writing text to the browser dynamically" on the page. This response is sent back to IIS and ultimately back to the browser, formatted using the <h1> tag. Although the process may seem complex, it happens so fast that a user rarely knows that a dynamic page is even being used.

See how easy that was? In this example, we manually wrote ASP code. The beauty in using Dreamweaver is that you don't have to. Dreamweaver writes all the necessary code for you. More on this later. For now, let's focus on getting our project configured so that we can use ASP to create dynamic Dorknozzle pages.

Configuring Dorknozzle to Run Under ASP

Up to this point, we've been working primarily from C:\Dorknozzle\<chapterfolder>. From now on, we'll work from C:\Inetpub\wwwroot\DorknozzleASP (assuming that you're using ASP). Because this is the case, we need to reconfigure the site definition to point to the new folder we've created. Furthermore, we need to configure the Testing Server category in the Site Definition window to provide Dreamweaver with information specific to the technology you plan on using for the defined site. To configure Dorknozzle to run under ASP, follow these steps:

1.

If you haven't downloaded the files for this chapter, do so now. Open the folder for Chapter 22, copy the contents out of the folder, and paste them into the newly created DorknozzleASP folder in C:\Inetpub\wwwroot. Now you have all the assets, images, library items, and an index.asp page to get you started. After you've copied the files over, you should have Assets, Images, and Library folders including a CSS file, an index.asp page, and the sample.asp page that you built in the previous section.

2.

Open Dreamweaver if you haven't already done so and choose the Manage Sites option from the Site menu.

3.

Select the existing Dorknozzle site from the list and click Edit. The Site Definition for Dorknozzle dialog appears.

4.

In the Site Name text box, rename the site from Dorknozzle to DorknozzleASP.

5.

Browse to the C:\Inetpub\wwwroot\DorknozzleASP\ folder within the Local Root Folder field. Leave everything else as is. The result appears similar to Figure 22.5.

Figure 22.5. Rename the site definition and set the local root folder to point to the C:\Inetpub\wwwroot\DorknozzleASP\ folder.


6.

Switch to the Testing Server category.

7.

Select the ASP VBScript option from the Server Model category.

8.

Choose the Local/Network option from the Access menu. New properties become available that allow you to configure the location of the remote folder as well as the URL prefix for the remote folder.

9.

Browse to the same C:\Inetpub\wwwroot\DorknozzleASP\ path in the Remote Folder text box. In most cases, this value is pre-populated when selecting the Local/Network option from the Access menu.

NOTE

When working with web applications, the ideal scenario is that you'll have a development machine, a production machine (server), and a testing server. Realistically, not everyone can afford another server just for testing purposes. Most of us will rely on the development machine to function as a testing server as well. For this reason, we'll simply leave the testing server path as is. If you do have a dedicated testing server, you'd probably still choose the Local/Network option from the Access tab; however, rather than finding the machine locally, you'd browse to it on the network.

TIP

As you've seen within the Access menu, other options are available for defining remote access to the testing server. Similar to the Remote Info category, when you select FTP and WebDAV, you're presented with options for configuring the Host, Host Directory, Login, and Password information. The RDS option is specific to ColdFusion. We'll get to that later in the chapter.

10.

Now enter the URL to our Dorknozzle site in the URL Prefix text box. This value should read http://localhost/dorknozzleasp/. Remember that localhost, like every other domain name (yahoo.com, google.com, and so on) is a URL that is accessible from a browser. Rather than accessing the site from a server miles away, the browser knows that localhost (and the IP address 127.0.0.1 associated with it) is the URL for the local instance of IIS (your computer). It doesn't have to look too far for your files. When you finish configuring this screen, the result will look similar to Figure 22.6.

Figure 22.6. Configure the Testing Server category.


11.

Click OK to close the Site Definition for DorknozzleASP window.

12.

Click Done to close the Manage Sites dialog.

You're now ready to begin building dynamic Dorknozzle pages using Dreamweaver and ASP!

Using ASP in Dreamweaver

Depending on the server technology you decide to use, features exposed in the Dreamweaver interface will change. For the most part however, you can bank on the fact that the following features will always be available in Dreamweaver when working with any server-side technology:

  • The Insert Bar: A visual representation of objects available in the Insert menu, the Application category in the Insert bar (shown in Figure 22.7), allows you to visually insert various types of dynamic objects onto your page.

    Figure 22.7. Use the Insert bar as a visual tool for inserting dynamic ASP objects on your page.


  • The Insert menu: Use the Application Objects and ASP Objects submenus in the Insert menu to insert both generic application objects as well as ASP specific objects.

  • The Application Panel: Split into four tabsDatabases, Bindings, Server Behaviors, and Componentsthe Application panel provides the means for connecting to and accessing database data, binding that data to elements on the page and also accessing the various application objects that were also available from the Insert menu. When working with dynamic pages in Dreamweaver, you should always have this panel open. The panel is shown with more detail in Figure 22.8.

    Figure 22.8. Use the Application panel when working with databases, binding database data to your dynamic pages, and working with various application objects.


    NOTE

    Although the Components panel is available as an option, it is inactive under the ASP server model. For the most part, this option is only available under the ASP.NET and ColdFusion server models.


  • The Tag Chooser: If you want to make fine-tuned changes in your ASP code, you can always choose specific tags from the Tag Chooser, shown in Figure 22.9. When you choose an option from the Tag Chooser (available by choosing the Tag option from the Insert menu), the Properties dialog for the particular tag opens, allowing you to further customize attributes of the tag.

    Figure 22.9. Use the Tag Chooser to manually insert specific tags relating to the particular server-side technology.


  • The Reference Panel: If you ever need help regarding the various ASP objects, application objects, or tags, you can always reference them in the Reference panel, available by choosing the Reference option from the Window menu.

Earlier I mentioned that most of the dynamic functionality built into Dreamweaver is the same regardless of the server-side technology you decide to use. This becomes obvious with the Insert, Application Objects submenu and the Application category in the Insert bar. The objects listed in these menus expose generic functionality that remains consistent regardless of server-side technology. What does change is the option below the Application Objects option in the Insert menu. This option (which varies from ASP Object, ASP.NET Objects, ColdFusion Objects, and PHP Objects, depending on which server-side technology you decide to use), displays specific content accordingly.




Macromedia Dreamweaver 8 Unleashed
Macromedia Dreamweaver 8 Unleashed
ISBN: 0672327600
EAN: 2147483647
Year: 2005
Pages: 237
Authors: Zak Ruvalcaba

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net