Vous êtes sur la page 1sur 20

ASP

R.I.Minu CSE,JCE

R.I.Minu,CSE, Jerusalem College of Engg

INTRODUCTION
ASP is a powerful tool for making dynamic and interactive Web pages. Active Server Pages (ASP) is a server side scripting language that lets a webmaster transform the plain, static web site into a dazzling, dynamic solution. With Microsoft's server side scripting language you can gather data from your site's visitors, use sessions, cookies, application variables, and more
R.I.Minu,CSE, Jerusalem College of Engg

SETUP

Open your control panel. Click Start -> then Settings -> then Control Panel Select and Open "Add or Remove Programs" On the left column of the popup window select "Add or Remove Windows Components" Scroll down until you see Internet Information Services (IIS) If IIS is not checked then check it, otherwise you already have IIS installed on your computer Click Next and follow the on screen instructions from the installer When it has completed, open up Internet Explorer and type in http://localhost If IIS was install appropriately you should be taken to the welcome screen http://localhost/localstart.asp

R.I.Minu,CSE, Jerusalem College of Engg

RUNNING
Open up "My Computer" or "Windows Explorer" so that you can view your system's files and directories. Select and Open the C drive (C:) Double click the Inetpub folder Double click the wwwroot folder - The full path to this location is "C:\Inetpub\wwwroot" for you advanced users Within the wwwroot directory locate the "localstart.asp" file.
R.I.Minu,CSE, Jerusalem College of Engg

Basic Example
1) <html> <body> <% ="Hello World!" %> </body> </html> 2) <html> <body> <% response.write("My first ASP script!") %> </body> </html> 3) <%@ language="javascript"%> <html> <body> <% Response.Write("Hello World!") %> </body> </html>

Using VB Script

Using Java Script

R.I.Minu,CSE, Jerusalem College of Engg

Output of (1)

R.I.Minu,CSE, Jerusalem College of Engg

Output of (2)

R.I.Minu,CSE, Jerusalem College of Engg

Output of (3)

R.I.Minu,CSE, Jerusalem College of Engg

FORM
Aspform.html
< html> <head><title> ASP form demo </title> </head> <body> <form method="GET" action="http://localhost/minu/simpleform.asp"> Name <input type="text" name="Name"/> Age <input type="text" name="Age"/> <input type="submit" /> </form> </body> </html>

simpleform.asp
<% Dim name, age name = Request.QueryString("Name") age = Request.QueryString("Age") Response.Write("Name: " & name & "<br />") Response.Write("Age: " & age & "<br />") %>

R.I.Minu,CSE, Jerusalem College of Engg

output

R.I.Minu,CSE, Jerusalem College of Engg

Output

R.I.Minu,CSE, Jerusalem College of Engg

#include Directive
Here is a file called "mypage.asp": <html> <body> <h3>Words of Wisdom:</h3> <p><!--#include file="wisdom.inc"--></p> <h3>The time is:</h3> <p><!--#include file="time.inc"--></p> </body> </html> Here is the "wisdom.inc" file: "One should never increase, beyond what is necessary, the number of entities required to explain anything." Here is the "time.inc" file: <% Response.Write(Time) %>
R.I.Minu,CSE, Jerusalem College of Engg

Global.asa
The Global.asa file is an optional file that can contain declarations of objects, variables, and methods that can be accessed by every page in an ASP application. The Global.asa file can contain only the following:
Application events Session events <object> declarations TypeLibrary declarations the #include directive
R.I.Minu,CSE, Jerusalem College of Engg

Global.asa (Cont..)
A Global.asa file could look something like this: <script language="vbscript" runat="server"> sub Application_OnStart 'some code end sub sub Application_OnEnd 'some code end sub sub Session_OnStart 'some code end sub sub Session_OnEnd 'some code end sub </script>

R.I.Minu,CSE, Jerusalem College of Engg

Object

ASP Build in Object


Description
Describes the methods, properties, and collections of the object that stores information related to the entire Web application, including variables and objects that exist for the lifetime of the application. Describes the properties of the object that stores information about an error condition. Describes a wrapper for the COM+ ObjectContext object, which provides methods and events that are used only for transaction processing. Describes the methods, properties, and collections of the object that stores information related to the HTTP request. This includes forms, cookies, server variables, and certificate data. Describes the methods, properties, and collections of the object that stores information related to the server's response. This includes displaying content, manipulating headers, setting locales, and redirecting requests. In a component, the ScriptingContext object returns references to the ASP built-in objects; however, this is an obsolete and unsupported method, removed in IIS 4.0. Use the COM+ ObjectContext object to return references to the ASP built-in objects. For more information, see COM+ ObjectContext Reference to the ASP Built-In Objects. Describes the methods and properties of the object that provides methods for various server tasks. With these methods you can execute code, get error conditions, encode text strings, create objects for use by the Web page, and map physical paths. Describes the methods, properties, and collections of the object that stores R.I.Minu,CSE, Jerusalem College information related to the user's session, including variables and objects of Engg that exist for the lifetime of the session.

Application Object

ASPErr Object ObjectContext object Request Object

Response Object

Scripting Context Object

Server Object

Session Object

ASP Component
AdRotator BrowserCap Content Linking Content Rotator

R.I.Minu,CSE, Jerusalem College of Engg

AdRotator
Banner.asp <% url=Request.QueryString("url") If url<>"" then Response.Redirect(url) %> <html> <body> <% set adrotator=Server.CreateObject("MSWC.AdRotator") response.write(adrotator.GetAdvertisement("ads.txt")) %> </body> </html> Ads.txt REDIRECT banners.asp * w3s.gif http://www.w3schools.com Free Tutorials from W3Schools 50 xmlspy.gif http://www.altova.com XML Editor from Altova 50

R.I.Minu,CSE, Jerusalem College of Engg

Browser Capabilities
<html> <body> <% Set MyBrow=Server.CreateObject("MSWC.BrowserType") %> <table border="0" width="100%"> <tr> <th>Client OS</th><th><%=MyBrow.platform%></th> </tr><tr> <td >Web Browser</td><td ><%=MyBrow.browser%></td> </tr><tr> <td>Browser version</td><td><%=MyBrow.version%></td> </tr><tr> <td>Frame support?</td><td><%=MyBrow.frames%></td> </tr><tr> <td>Table support?</td><td><%=MyBrow.tables%></td> </tr><tr> <td>Sound support?</td><td><%=MyBrow.backgroundsounds%></td> </tr><tr> <td>Cookies support?</td><td><%=MyBrow.cookies%></td> </tr><tr> <td>VBScript support?</td><td><%=MyBrow.vbscript%></td> </tr><tr> <td>JavaScript support?</td><td><%=MyBrow.javascript%></td> </tr> </table> </body> </html>

R.I.Minu,CSE, Jerusalem College of Engg

Output

R.I.Minu,CSE, Jerusalem College of Engg

Content Link
Contentlink.asp <html> <body> <% set cr=server.createobject("MSWC.ContentRotator") response.write(cr.ChooseContent("C:\Inetpub\wwwroot\minu\Content.txt")) %> </body> </html> Content.txt %% #3 <h2>This is a great day!!</h2> %% #3 <img src="smiley.gif"> %% #4 <a href="http://www.w3schools.com">Visit W3Schools.com</a>
R.I.Minu,CSE, Jerusalem College of Engg

Vous aimerez peut-être aussi