Friday, January 6, 2012

How to Write a Script in ASP?

ASP or Active Server Pages is a scripting language created by Microsoft back in 1996 as part of Internet Information Server (IIS) 2.0. With ASP, you can create web pages that are dynamic in nature and that allow the users to interact with the website. ASP is processed at the server level, and the results are then returned to the web browser. ASP can be as simple as writing, "Hello World! I'm learning how to write script in ASP," on a web page or as complex as submitting and retrieving data from a database like Microsoft Access or Microsoft SQL. Make sure your website hosting plan is Windows based and supports ASP

Instructions 1.
Use either a text editor or a WYSIWYG editor to write your ASP code. You should have a functional understanding of HTML coding before attempting ASP scripting. As an example, Microsoft FrontPage is used to write code in this article, but Notepad works just as well. Make sure to save your files with the .asp extension and not .htm or .html; otherwise, the server will not process the ASP code and most likely will return an error message in the browser.

2.
ASP coding using Notepad
Write your code between the delimiters (the percent sign with brackets) <% %> so the server knows to process the code correctly and return the results to the browser.



3.  ASP coding using Microsoft Frontpage
Start your first line of code with the scripting language (in classic ASP) which by default is VBScript. Then you can continue with HTML coding and any other ASP scripting needed.
<%@ Language=VBScript %>
<html>
<body>
<% Response.Write "Wow! I'm Learning ASP" %>
</body>
</html>
Example of connection to an Access Database using ASP:
<%
Set dbConn = Server.CreateObject("ADODB.Connection")
dbConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("MyDatabase.mdb")
Set rsCustomers = Server.CreateObject("ADODB.Recordset")
rsCustomers.Open "SELECT * FROM Customers", dbConn,1,3
%>
 
4. Teach yourself ASP by taking advantage of the many resources on the Internet that make it easy to create functional websites. There are many things you can accomplish with ASP to make your website a dynamic place for users.


Tips & Warnings

You need to host your site with a hosting company that uses Windows-based servers that are compatible with ASP.
//