techpreparation-homepage

Home  Interview Questions  Aptitude Questions  Tutorials  Placement Papers  Search  Resume Guide  Soft Skills  Video  Forum  Blog


Technical Interview Questions

Visual Basic Interview Question
.NET Web Interview Questions
.NET Interview Questions
C# Interview Questions
                              .........More

Source Codes
Asp .NET Source Codes
Asp VB Script Source Codes
                              .........More

Soft Skills
Communication Skills
Leadership Skills
                              .........More

Subscribe to our Newsletters
Name:
Email:

 

 

  

Asp/VB Script Source Codes

VBScript for ASP

<H2><B>Introduction</B></H2>
<P>I have recently received a lot of e-mails from people who understand the concepts of Active Server Pages (ASP) and the techniques discussed in other tutorials, but are getting hung up on the code. What is worse is that I almost always hear that novice ASP developers can never find resources that are simple, easy to read, and for the "just getting my feet wet" crowd. Let's face it, there are plenty of advanced resources out there, so I have decided that it is time to go back to the basics and help out those who would love to use ASP but have no idea where to begin. Welcome to VBScript 101!
<P>VBScript &nbsp;is the heart of ASP. It is the scripting language that ASP defaults to and is the language I recommend that you use for all your ASP development. You can use server-side JScrip, but there is no real advantage to doing so. Meanwhile, a big disadvantage is that the ASP community has pretty much standardized on VBScript. Most of the tutorials you see around the Net and in books will not even mention JScript, other then in passing. This article is going to give you a very basic understanding of using VBScript in an ASP page. Please note that this article is <B>not</B> going to teach you how to use VBScript to do client-side operations. Of course, there will be more overlap then not, but the intent of this article is focused on using VBScript for ASP, which should be why you are reading it the first place!
<P>
<H2><B>Scripting - What is It?</B></H2>
<P>The big question — just what is a scripting and why should you care? Not only is it a big question, it is a good question! In very unacademic and somewhat nebulous terms, scripting is writing code that is not compiled before it is run. What does that mean? It means that unlike your standard C++ or Visual Basic type code, scripting languages like Perl, VBScript, JavaScript/JScript, and others, do not have to be run through a compiler (something that translates our human-readable code into code the machine can understand) to be executed or run. Scripting code is interpreted, or "compiled on the fly" so to speak. For instance, when you run a Perl script in a CGI-BIN directory, the script is "interpreted" by the perl "interpreter" and the results are posted back per your instructions. VBScript (which stands for Visual Basic Script) works pretty much the same way except it takes its syntax base from its parent language — the full blown and compiler dependent Visual Basic. And if you are smart, you would guess that JavaScript and JScript work the same way, originally inheriting their syntax base from Sun's Java (and more recently the standards set by ECMAScript).
<P>Let's look at a simple client-side JavaScript as an illustrative example. Pretend you have a nice HTML page with the following JavaScript in the heading.
<P><PRE> &lt;script language="JavaScript1.2" type="text/css"&gt;
&lt;!-- //hide from older browsers
document.write('Hello Web World');
//--&gt;
&lt;/script&gt;
</PRE>
<P>This tiny script will write "Hello Web World" on the top of the page when a user visits it. Rather then being compiled, stored and run as an executable every time a visitor hits, JavaScript (or other scripting languages) enables you to embed commands into the actual HTML that are "freshly" executed each time the page is requested. Line-by-line the code is "interpreted" and the results are, for all intents and purposes, instantaneous. One thing to note about client-side scripting is that performance is largely dependent on the client's hardware, software and connection speed. When we get into VBScript for ASP, we will be dealing with server-side scripting, so performance will be a function of the Web server we are using. For most of you it will still be your own machine!
<P>Which leads me to a very important thing you need to know about VBScript for ASP. You need somewhere to test your code since it will not function client-side. That is where Internet Information Services (IIS) or Personal Web Server (PWS) come in. If you do not have a hosting agreement with some third-party Web host that supports ASP, you will need to configure your own PC or laptop to act as the Web server. You can do this by downloading <A href="http://www.microsoft.com/Windows/ie/pws/default.htm">Personal Web Server for Windows 9x</A> or by using IIS for NT4 (can be installed with the Option Pack) and Windows 2000 (comes on the CD). These two Web servers will configure your system to have a directory on your C drive called <I>InetPub</I>. Underneath InetPub will be a directly called <I>wwwroot</I>. This directory is where you will want to store all your ASP pages. To access and test your pages you will need to point your Web browser to http://127.0.0.1/nameoffile.asp or to http://localhost/nameoffile.asp; then you are all set!
<P>Finally, when you are testing the code illustrated below, make sure you put it in between ASP's &lt;<CODE>% '...lines and lines of vbscript... %</CODE>&gt; server-side tags. These tell the server that it should interpret the code inbetween. If you want to see the value of any variables on screen when you are testing, use &lt;<CODE>%= nameOfVariable %</CODE>&gt; and it will be displayed in your browser. </P>


<<<----- Return to Asp/VB Script Source Code Questions Page.


Have a Question ? post your questions here. It will be answered as soon as possible.

Check Microsoft .Net Interview Questions for more Microsoft .Net Interview Questions with Answers.

Check .Net Database Interview Questions for more .Net Database Interview Questions with answers

Check Job Interview Questions for more Interview Questions with Answers