All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
Quick Search for:  in language:    
active server pages, ASP, vbscript,tutorial, newbie, beginner, how, to, how to program, help
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 281,603. lines
 Jobs: 101. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login

NEW! LEARNING CENTER
Special educational offers, white papers, webcasts, podcasts

  NEW! Download Rational Performance Tester V8 (download now)
  NEW! Download Rational Functional Tester V8 (download now)
  NEW! Download Rational Service Tester for SOA Quality V8 (download now)
  NEW! Teleconference: Quality In Action - Using Rational Quality Manager with Functional, Performance and Web Service Testing Products (download now)
  NEW! Introducing IBM Rational AppScan Developer Edition – easing security testing by non-security professionals (download now)

 

 


Latest postings for ASP/ VbScript.
Click here to see a screenshot of this code!IT Department Complaint Register
By AMIT MESHRAM on 12/2

(Screen Shot)

Chat
By G.Chenna Subramani on 11/26


Click here to see a screenshot of this code!Mess Officer Management System (Sistem Pengurusan Mess Pegawai)
By Mohd Fauzi on 11/23

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 

Back to Tutorial Index

Create Your First ASP Script in 10 Minutes Flat!
By Kathi O'Shea (kathi@web-savant.com)
Reprinted with permission from http://www.web-savant.com/users/kathi/asp




Ready, Set...Go!

First of all, you will need a server to run your ASP scripts. If you are running Windows 98, the Personal Web Server is included on the CD. If you're not sure if you have installed PWS, check in Control Panel -> Add & Remove Programs -> Windows Setup -> Internet Tools. If The box next to Personal Web Server is checked, you're in business! If not, click on the box, and click OK. Be sure to have your Windows 98 CD handy, as you'll probably need it to complete the install process.

If you are running Windows 95 or NT 4, download NT Option Pack 4, which is free to download and use. Win95 users: don't let the name fool you - you'll have the option of specifying Win95 during the download process. Once its downloaded (its a BIG file!), install it following the directions provided by the install routine - its a painless process.  

  Top of Page

Your First Script
ASP is usually written using Visual Basic, Scripting Edition (VBScript) or JScript. I use VBScript, as I have a background in programming with BASIC, and the jump to VBScript was relatively painless, despite having been away from BASIC programming for quite some time. The examples here are all done in VBScript.

Open up a text editor - Notepad or any other plain text editor will do. A text-based HTML editor will also work (I do most of my scripting with Homesite). We'll start out with a very simple script... a take-off on the old "Hello World" script.

We'll begin by writing a bit of standard html. This sets up the html page that the script will write to. Then, we'll put in a bit of vbscript, which is enclosed by
<% and %>, to write to the page and generate today's date. We'll then end the script with standard HTML.

</font></font> <p><font size="3" face="Verdana">My First ASP script <font size="2">      <% Dim Today ' declares Today as a variable Today = Date() ' makes Today's value today's date Response.Write "Hello, ASP World!" Response.write "<br>My first script was created " response.Write(Today) ' now we'll end the response response.end %> </font>

Let's analyse the script portion briefly. First you see the Dim statement. While it is generally considered good form to declare your variable names with a Dim statement, it isn't required. Now that I have declared my variable, I next give it a value. Date() returns today's date.

Next, I want the script to write to the page, so I use response.write in the next three lines. The first two lines of the response writes text to the screen - when doing this, always remember to enclose the text string in double quotes. You'll note that I've included an HTML tag in the response just as long as its within the double quotes. The third response line returns the value of Today. Note that since VBScript is not case sensitive, I can get away with capitalizing "response.write" differently in all three lines.

The next line, the one that begins with a single quote, is a comment. Comments are extremely handy - adding comments to your scripts not only helps you remember exactly what you were trying to accomplish with a particular part of the script, but also helps others who see your script to understand your logic.

The final line ends the response. If you have no further scripting on the page, you can omit this. I use the response.end statement generally when I'm using a conditional statement (if then...else) and want to go no further if certain conditions are met.

  Top of Page

Running Your Script
In order to be able to run your ASP scripts, you must first save the script ,using the .ASP extension, to a directory within your wwwroot. The standard path for NT Option Pack is c:\inetpub\wwwroot and for Win98 PWS (and older win95 versions of PWS if I recall correctly) its c:\webshare\wwwroot.

You must also properly configure the directory in which you save your ASP scripts. The directory must allow scripts access, and generally its a good idea to turn off read access in that directory for security reasons. To check this, fire up your web server administration screen and right-click on your scripts directory.

Now its time to see your script in action. Run your favorite browser, and point it to http://localhost/script_directory_name/script_name.asp, where script_directory_name is the actual name of the directory containing your script and script_name.asp is the name of your script. Now you should see your first effort come to life. Congratulations - you have just run your first script!

  Top of Page

Setting Up a DSN
If you plan to use ASP to access a database, you will want to set up a DSN (Data Source Name) for each database you'll use. If you plan to try out some of the sample database scripts from this site, you will need to set this up before trying any of the scripts.

Setting up the DSN is a simple process. Simply double-click the ODBC applet in the Control Panel, choose the System DSN tab, and click Add. Choose the type of database you'll be working with - the sample database from this site is MS Access - then click finish. You'll then need to type in the database name in the Data Source Name box, and click Select. Next you'll navigate to the drive and directory where the database is located, click on the file name and click OK on that window and the one behind it. Now you can refer to the database by name in your scripts and the system will know which ODBC driver to use and where the database is located.

  Top of Page

Neat, But...What Now?
You have just sampled a tiny part of what ASP is all about. But, what else can ASP do? Lots of things! You can use it for browser detection, server variables such as what IP and referring page a site's user comes from, reading and writing to a database or text file, surveys and quizzes, electronic commerce, chat, message boards...and much more. With add-on server components, you can email web form responses, upload and download files, rotate banners - the possibilities are endless.


Back to Tutorial Index








 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2008 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.