Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Active Server Pages

Similar presentations


Presentation on theme: "Introduction to Active Server Pages"— Presentation transcript:

1 Introduction to Active Server Pages
Active Server Pages (ASP) ASP Architecture Basic ASP Scripting Techniques ASP Object Model Request Object Response Object

2 ASP Architecture

3 Microsoft’s solution for developing dynamic web pages
ASP Architecture Microsoft’s solution for developing dynamic web pages Uses VBScript, a variant of Visual Basic A subset of VB Internet-enabled Object-oriented architecture Provides objects for various functions such as database access, file access, etc. Supported by Microsoft’s IIS and Personal Web Server

4 Executed by web browsers Can be VBScript, Javascript, etc.
Scripting in ASP An ASP can consist of HTML code Server side script Client side script Executed by web browsers Can be VBScript, Javascript, etc. Executed by web servers May be VBScript or Javascript, etc.

5 Dynamically edit, change or add any content of a Web page
What can ASP do for you Dynamically edit, change or add any content of a Web page Respond to user queries or data submitted from HTML forms Access any data or databases and return the results to a browser Customize a Web page to make it more useful for individual users The advantages of using ASP instead of CGI and Perl, are those of simplicity and speed Provides security since your ASP code can not be viewed from the browser Since ASP files are returned as plain HTML, they can be viewed in any browser Clever ASP programming can minimize the network traffic

6 <title>My First ASP Page</title> </head>
A Simple ASP Example <html> <head> <title>My First ASP Page</title> </head> <body> <% Response.Write("Welcome to my first ASP generated web page.") %> <br /> <%= "Today is " & date() & " and the time is " & time() %> </body> </html>

7 Create a new web application in FrontPage
Mapping your web folder (dt211-3studentusername) from “erin.student.comp.dit.ie” to your machine. Select start, Programs, MicroSoft FrontPage Select Open Site Type in: Now you should be able add your ASP file now.

8 <title>Document title</title>
A Client side example <html> <head> <title>Document title</title> <script language="vbscript"> sub vbs alert("This is VBScript") end sub </script> <script language="javascript"> function js() { alert("this is JavaScript") }

9 A Client side example, cont.
</head> <body> Select button: <input type="button" Name="vbs" value="VBScript" onclick="vbs()" /> <input type="button" Name="js" value="Javascript" onclick="js()" /> </body> </html>

10 Control Flow statements are divided into 2 types. Conditional Loop
Control Flow in ASP Control Flow statements are divided into 2 types. Conditional Loop Conditional statements are If…Then…Else Select…Case Looping statements are Do…Loop For…Next While…Wend

11 <title>ASP Loop</title> </head> <body> <%
A Loop example <html> <head> <title>ASP Loop</title> </head> <body> <% Dim i for i = 1 to 6 response.write("<h" & i & ">This is header " & i & "</h" & i & ">") next %> </body> </html>

12 <head> <title>ASP Loop</title></head>
A If example <html> <head> <title>ASP Loop</title></head> <body> <% Dim h h = hour(now()) response.write("<p>" & now()) response.write(" (Irish Time) </p>") If h < 12 then response.write("Good Morning!") else response.write("Good day!") end if %> </body> </html>

13 There are two types of procedures, “Sub” and “Function”.
Procedures are subroutines that can be called by the main program. It contains a different script level this separating local variables from global variables. There are two types of procedures, “Sub” and “Function”. “Sub” normally doesn’t return a value while “Function” returns a value

14 <html><head> <title>ASP Loop</title>
A procedures example <html><head> <title>ASP Loop</title> <% sub vbproc(num1,num2) response.write(num1*num2) end sub %> </head><body><p> The result of the calculation is: <%call vbproc(3,4)%> </p><p> Or, you can call a procedure like this: </p><p> The result of the calculation is: <%vbproc 3,4%> </p> </body> </html>


Download ppt "Introduction to Active Server Pages"

Similar presentations


Ads by Google