Intrinsic Objects

Creating an Active Server Page

Although you can use any text editor to create an ASP, Microsoft Visual InterDev provides a more graphical and robust environment. To get the full benefits of Microsoft Visual InterDev, first create a project for the Web pages to reside in. This exercise uses a Web project because you must use a Web server that supports ASP in order to test ASP.

* To create a new project

  1. Start Microsoft Visual InterDev.
  2. On the File menu, click New .
  3. From the Projects tab, select Web Project Wizard .
  4. In the Project name : box, enter sample and click OK .
  5. The Web Project Wizard will prompt you for a server name, be sure localhost is entered in the box. Click Next .
  6. Leave the Web site name of sample in the box and click Finish .
* To create a new Active Server Page
  1. On the File menu, click New .
  2. Select the Files tab and click Active Server Page .
  3. In the Add to project box, be sure the sample project is selected.
  4. In the File name box, enter MyPage .
  5. The sample folder should already be listed in the Location box.
  6. Click OK .

    An Active Server Page template appears.

    The first line of script sets the server-side language for the page. For example, if you set the language to VBScript, the following line of script will be added to the Active Server Page:

     <%@ LANGUAGE="VBSCRIPT" %> 
  7. Replace the <-- Insert HTML Here --> with the following VBScript:
     <% If Hour(Now) < 12 Then %> Good Morning! <% Else %> Good Afternoon! <% End If %> 
  8. In the Workspace window, right click mypage.asp and select Preview in Browser .

    When Visual InterDev prompts you to save the file, click Yes .

    Depending upon the time on your computer, the appropriate greeting will be displayed.

* To change the default scripting language
  1. From the Tools menu, click Options .
  2. Scroll to select the HTML tab.
  3. Under Default Languages, choose between VBScript and JavaScript for either the InterDev Script Wizard or Active Server Pages.

Lesson Summary

Active Server Pages are processed by server extensions running on the Web server. An ASP script runs when a browser requests an .asp file from a Web server. The Web server calls the ASP, which executes script commands, and then sends an HTML page to the browser.

Server-side script is contained in either <%%> delimiters, or in a <SCRIPT> tag. When a Web server processes an ASP, it runs any script between the <%%> delimiters. To add server-side script to an HTML <SCRIPT> tag, you must set the RUNAT attribute to Server .

The ASP architecture contains five intrinsic objects that allow you to create additional functionality in your applications. Using intrinsic objects you can store information for a specific user, retrieve information passed from the user to the server, send output to the user , and work with the properties and methods of components on the server.



Microsoft Windows Architecture Training
Microsoft Windows Architecture for Developers Training Kit
ISBN: B00007FY9D
EAN: N/A
Year: 1998
Pages: 324

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