190 likes | 355 Views
Chapter 5. ASP Control Constructs. ASP Statements. Action Statements: Carry out a task Control Statements: Direct the execution of the action statements. Control Statements. Branching Structures Performs a test. Based on the result a set of code will be executed and others skipped.
E N D
Chapter 5 ASP Control Constructs
ASP Statements • Action Statements: Carry out a task • Control Statements: Direct the execution of the action statements
Control Statements • Branching Structures • Performs a test. Based on the result a set of code will be executed and others skipped. • Looping Controls • Allows the same blcok of code to be repeated a number of times or as long as a condition exists. • Jumping Controls • Allows the program to pause execution of current code and jump to a different block of code.
Branching Structures • If. . . Then . . . Else • Select . . . Case
Branching Statements • If . . . Then • Common Errors (pp. 146) • Basic Rules (pp. 146) • Select Case • Common Errors (pp. 148-9) • Basic Rules (pp. 150)
Looping Controls • For . . . Next • Do . . . While
Looping Controls • For . . . Next • Common Errors (pp. 155-6) • Basic Rules (pp. 156) • For Each . . . Next • Used for Arrays • Do . . . While • Common Errors (pp. 161) • Basic Rules (pp. 161)
Jumping Controls • Call • Functions • Exit
Jumping Structures • Procedure • Carry out an action like output information on a page. • Function • Carry out an action and return and answer to the code. For example, calculating the days before a payment is due.
Procedure <% Sub Welcome Response.Write "Welcome to my CyberHome." End Sub %> <H1>Doc Rea's Site</H1> <%call Welcome%>
Functions (5 ideas) • Use Function and End Function • The Function receives some information from the main code • Do not have to declare this variable using Dim • Once calculation is complete, it has to report result back to main ASP code. • To call a function simply type the named function followed by parentheses • Send the information from your main body of code to the function. Put whatever to be sent to the function in the parentheses.
Functions • Common Errors (pp. 169)
Chapter 6 Objects, Properties, Methods, and Events
Object • An object can be almost anything in object-oriented programming. • Write programs to make objects interact with one another, change properties (or attributes), etc. • Phone example in book works well.
More Terms • Instance (pp. 177) • Properties (pp. 177-8) • Methods (pp. 178-181) • Parameters • Return Values • Encapsulation
Events • A way for an object to tell the user that something has happened. • Synchronous: first action must be complete before second can occur • Asynchronous: Second action can begin at any time regardless of first
The Telephone Object • Available for download
ASP Object Model • Server object (Chapter 10) • Application object (Chapter 9) • Session object (Chapter 9) • Request object (Chapter 7) • Response object (Chapter 8) • ObjectContext object (not in text)
Valuable Links • Quick listing of properties and methods of the ASP built-in objects from ASP101.com • http://asp101.com/resources/aspobject.asp • Great reference for learning more about the built-in objects • http://help.activeserverpages.com/iishelp/iis/htm/asp/intr1orp.htm • Quick reference card for the built-in objects • http://help.activeserverpages.com/iishelp/iis/htm/asp/iiwaref.htm