Académique Documents
Professionnel Documents
Culture Documents
R.I.Minu CSE,JCE
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
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
Output of (1)
Output of (2)
Output of (3)
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 />") %>
output
Output
#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>
Object
Application Object
Response Object
Server Object
Session Object
ASP Component
AdRotator BrowserCap Content Linking Content Rotator
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
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>
Output
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