EIW - ASP Introduction1 Active Server Pages VBScript.

Slides:



Advertisements
Similar presentations
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Advertisements

Introduction to JavaScript
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
1 Today: Introduction to ASP- Part 1 Explain the client/server architecture Explain Web-based client/server applications Understand the essentials of Active.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Introduction to ColdFusion By Tom Dubeck. Overview What is ColdFusion? How does it compare to other scripts? Some example code. Why you might want to.
1 Active Server Pages Active Server Pages (ASPs) are Web pages ASP = server-side scripts + HTML The appearance of an Active Server Page depends on who.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Introduction to Active Server Pages
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
ALBERT WAVERING BOBBY SENG. Week Whatever: PHP  Announcements/questions/complaints.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
Lecture Note 3: ASP Syntax.  ASP Syntax  ASP Syntax ASP Code is Browser-Independent. You cannot view the ASP source code by selecting "View source"
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
PHP. Why should we learn web programming? No need write socket programming. - You can forget TCP/IP & OSI layers. - Web server handles socket tasks for.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
INT213 Week 1.  A Named storage area (in RAM) that can hold a value (like a mailbox holding a letter)  Contents of a variable can be assigned, changed.
MS Visual Basic Applications Walter Milner. Event-driven programming Standard approach for GUIs Contrast with old character interfaces – program determines.
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
ALBERT WAVERING BOBBY SENG. Week 4: JavaScript  Quiz  Announcements/questions.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Applications Development
CNS 1120 Exam 1 Review. Programming Language Elements Syntax = the rules to follow Syntax = the rules to follow Semantics = the meaning of symbols Semantics.
1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Introduction to Programming Lecture Note - 2 Visual Basic Programming Fundamentals.
Visual Basic Programming I 56:150 Information System Design.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
CIVIL AND GEOMATIC ENGINEERING FT Okyere. CIV 257- COMPUTER PROGRAMMING Lecture 3.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
FP512 WEB PROGRAMMING 1 PREPARED BY: PN. NUR SYUHADA BINTI MOHAMAD.
Controlling Program Flow with Decision Structures.
ASP Syntax Y.-H. Chen International College Ming-Chuan University Fall, 2004.
End of the beginning Let’s wrap up some details and be sure we are all on the same page Good way to make friends and be popular.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
CGS 3066: Web Programming and Design Spring 2016 PHP.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
By “FlyingBono” 2009_02By FlyingBono.  ASP code is embedded in HTML using tags.  A ASP scripting block always starts with.  Server scripts are executed.
INT213 – WEEK 1 ASP tags and comments Variables, Constants, and "Literals" Simple Output.
VISUAL BASIC 6.0 Designed by Mrinal Kanti Nath.
Exploring JavaScript Ch 14
QuickBasic Jason Mallory.
PHP Introduction.
Introduction to JavaScript
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Introduction to JavaScript
JavaScript CS 4640 Programming Languages for Web Applications
PHP: Hypertext Preprocessor
PHP an introduction.
Quick Test Professional Training Part 1
Web Programming and Design
Intro to Programming (in JavaScript)
Presentation transcript:

EIW - ASP Introduction1 Active Server Pages VBScript

EIW - ASP Introduction2 CGI vs. "Smart Server" HTTP Server CGI Program request response request HTTP Server request response foo Hello World <% Dim i FOR i=1 TO 10 Response.Write(" "&i&" ") NEXT %> foo Hello World <% Dim i FOR i=1 TO 10 Response.Write(" "&i&" ") NEXT %> ASP Document

EIW - ASP Introduction3 Active Server Pages The document contains some commands that the server processes. –Microsoft ASP supports VBScript (similar to Visual Basic) JScript (Javascript) There are other languages supported this way (by some HTTP Servers). – PHP, Cold Fusion, JSP

EIW - ASP Introduction4 Sample Document foo Hello World <% Dim i FOR i=1 TO 3 Response.Write(" "&i&" ") NEXT %> foo Hello World <% Dim i FOR i=1 TO 3 Response.Write(" "&i&" ") NEXT %> foo Hello World foo Hello World Browser gets this Server reads this

EIW - ASP Introduction5 VBScript Another language to learn! Microsoft Only. Very Different Syntax (compared to C++, JavaScript, Perl). No semicolons! Objects The server provides lots of Web programming support (many tasks are easier).

EIW - ASP Introduction6 VBScript Language Variables –variant Operators –some are the same, others different… Control Structures –same stuff, different syntax Subroutines & Functions –collectively called procedures Objects –lots of functionality provided by objects

EIW - ASP Introduction7 VBScript is not case sensitive foo is the same thing as FOO This applies to everything –variable names, constant names –keywords –subroutine/function names –object names

EIW - ASP Introduction8 VBScript Variables Data type: variant –can be anything (much like JavaScript & Perl). Some people name variables according to how they will be used: –intFoo Foo is an int –strFoo Foo is a string –objFoo Foo is an object

EIW - ASP Introduction9 Variable Declarations Variables don't have to be declared, but they can be using Dim Dim foo If you add the tag to the top of your document, the server will insist that all variables must be declared. –this is generally a good idea! Saves you from wasting time tracking down typos.

EIW - ASP Introduction10 What's up with Dim ? A holdover from the Basic programming language. Dim was for "Dimension" (used when declaring arrays). Send complaints to –Bill wrote the original Basic interpreter used on PCs

EIW - ASP Introduction11 Variable Scope Variables declared outside of a subroutine or function (VBScript has both) are global. Variables declared in a subroutine or function are created and destroyed each time the procedure is called. (local variables) You can also create Session variables and Application variables! (more about this later).

EIW - ASP Introduction12 Dim-witted Example <% Dim wit Dim sum sum=0 FOR wit=1 TO 3 Response.Write(" " & wit & " ") sUm = SuM + WIT NEXT %> Total is declares a variables named wit and sum case doesn't matter

EIW - ASP Introduction13 VBScript Arithmetic Operators SymbolOperation ^ Exponentiation - Subtraction (negation) * Multiplication / Division \ Integer Division Mod Modulus + Addition & String Concatenation

EIW - ASP Introduction14 VBScript Comparison Operators SymbolOperation = Equality <> Inequality < Less than > Greater than <= Less than or equal to >= Greater than or equal to Is Object equivalence

EIW - ASP Introduction15 Assignment vs. Equality The assignment operator is the same as the logical equals comparison operator. a=3 If a=3 Then b=7 End If This is assignment This is comparison

EIW - ASP Introduction16 VBScript Logical Operators SymbolOperation Not Logical Negation And Logical Conjunction Or Logical Disjunction Xor Logical Exclusion Eqv Logical Equivalence Imp Logical Implication

EIW - ASP Introduction17 Logical Example If a=3 or s="Hello" Then Response.Write(" BLAH ") End If

EIW - ASP Introduction18 Control Structures In VBScript they are called "Statements" If and friends Loops: For, For Each, While, Do Exception Handling: On Error Sub and Function Select Lots more…

EIW - ASP Introduction19 If Statements Inline (all on one line) If i > 3 Then a = 20 Else b = 30 Block If i > 3 Then a = 20 Else b = 30 End If keywords in blue

EIW - ASP Introduction20 Fancy Inline If s If A > 12 Then a=3 : b=4 : c=5 colon between each statement This must be all on one line!

EIW - ASP Introduction21 If Then ElseIf Else If A > 3 And s = "Sam" Then Asp = "fun-fun-fun" ElseIf A > 3 Then Asp = "fun-fun" ElseIf A > 1 Then Asp = "fun" Else Asp = "I want Perl back" End If

EIW - ASP Introduction22 For loops For counter=1 To 100 sum = sum + counter Next For counter=10 To 1 Step -1 sum = sum + counter Next

EIW - ASP Introduction23 Quick Exit For j=1 To 9 If x[j]=-1 Then Exit For End If sum = sum + j Next

EIW - ASP Introduction24 While loop i=0 While i<0 sum = sum + i i = i + 1 Wend

EIW - ASP Introduction25 Do loops Do While condition... Loop Do Until condition... Loop Do... Loop While condition Do... Loop Until condition

EIW - ASP Introduction26 Do Examples i=0 Do While i<10 sum = sum + i i = i + 1 Loop Do sum = sum – i i = i - 1 Loop Until i=0

EIW - ASP Introduction27 Do quick exit Do While i<10 grade = grade + hw[i] If sum > 100 Exit Do End If Loop Response.Write("HW Grade: " & grade)

EIW - ASP Introduction28 Exceptions Handling (Errors) Run time errors will result in the server sending error information to the browser (as part of the content). –This is great for debugging! –This is bad for production systems. generally want to handle errors ourselves instead of having the server send a cryptic message to the user.

EIW - ASP Introduction29 VBScript On Error You can tell VBScript what to do when a runtime error happens. –Each procedure can handle errors itself, or allow calling procedure to handle things. –Sometimes you just want to go on as if nothing happened. –Sometimes you need to handle errors with special code.

EIW - ASP Introduction30 Error Example i=3 While i>-2 j=10/i Response.Write("j is "&j&" ") i=i-1 Wend i=3 While i>-2 j=10/i Response.Write("j is "&j&" ") i=i-1 Wend j is j is 5 j is 10 Microsoft VBScript runtime error '800a000b' Division by zero /eiw/asp/err.asp, line 8 j is j is 5 j is 10 Microsoft VBScript runtime error '800a000b' Division by zero /eiw/asp/err.asp, line 8

EIW - ASP Introduction31 On Error Resume Next If you want to continue on as if nothing happened (usually not a good idea!). Execution continues at the statement after the one that is causing problems. Sets error handling until the end of a procedure (or another On Error statement).

EIW - ASP Introduction32 On Error Resume Next Example On Error Resume Next i=3 While i>-2 j=10/i Response.Write("j is "&j&" ") i=i-1 Wend On Error Resume Next i=3 While i>-2 j=10/i Response.Write("j is "&j&" ") i=i-1 Wend j is j is 5 j is 10 j is -10 j is j is 5 j is 10 j is -10 Old value of j !

EIW - ASP Introduction33 Better Example On Error Resume Next i=3 While i>-2 j=10/i If Err.Number > 0 Then Response.Write("j is a problem ") Err.Clear Else Response.Write("j is "&j&" ") End If i=i-1 Wend On Error Resume Next i=3 While i>-2 j=10/i If Err.Number > 0 Then Response.Write("j is a problem ") Err.Clear Else Response.Write("j is "&j&" ") End If i=i-1 Wend j is j is 5 j is 10 j is a problem j is -10 j is j is 5 j is 10 j is a problem j is -10

EIW - ASP Introduction34 On Error GoTo 0 You can turn off " On Error Resume Next " with the statement: On Error Goto 0 Stays off until end of procedure or another On Error Resume Next statement.

EIW - ASP Introduction35 Response.Write() Response Object –corresponds to the HTTP response –Method Write() sends text to the browser Response.Write(" Welcome ")

EIW - ASP Introduction36 Table of Squares Num Num Squared <% Dim i For i=1 To 10 Response.Write(" "&i&" ") Response.Write(" "&i^2&" ") Next %> Num Num Squared <% Dim i For i=1 To 10 Response.Write(" "&i&" ") Response.Write(" "&i^2&" ") Next %>

EIW - ASP Introduction37 Sending a single expression You can include the value of a single expression without Response.Write()

EIW - ASP Introduction38 Another way to do the Table of Squares Num Num Squared Num Num Squared