CIS 451: ASP.NET Debugging and Server-Side Includes Dr. Ralph D. Westfall February, 2009.

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
2440: 211 Interactive Web Programming JavaScript Fundamentals.
Server-Side vs. Client-Side Scripting Languages
JavaScript 101 Lesson 01: Writing Your First JavaScript.
ASP Tutorial. What is ASP? ASP (Active Server Pages) is a Microsoft technology that enables you to make dynamic and interactive web pages. –ASP usually.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Lec6 P 1 CP2030 Visual Basic For C++ programmers Copyright © University of Wolverhampton CP2030 VBFC Lecture 6 Back To Index v Procedures and Parameters.
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.
Python and Web Programming
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Project 2 Issues Dr. Ralph D. Westfall February, 2006.
Creating an HTML page Skills: edit and debug HTML pages IT concepts: text editor This work is licensed under a Creative Commons Attribution-Noncommercial-
CIS101 Introduction to Computing Week 09 Spring 2004.
Copyright © 2001 by Wiley. All rights reserved. Chapter 3: Variables, Assignment Statements, and Arithmetic Variables Assignment Statements Arithmetic.
Stored Procedures Dr. Ralph D. Westfall May, 2009.
Course Textbook: Build Your Own ASP.Net Website: Chapter 2
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Advanced Web 2012 Lecture 4 Sean Costain PHP Sean Costain 2012 What is PHP? PHP is a widely-used general-purpose scripting language that is especially.
MIS 3200 – Unit 6.2 Learning Objectives How to move data between pages – Using Query Strings How to control errors on web pages – Using Try-catch.
ASP.NET Dr. Ralph Westfall May, Web Development Problem HTML designed to display static pages only interactive when user clicks links  can’t provide.
CIS 338: Creating ActiveX Controls Dr. Ralph D. Westfall March, 2003.
Server Side Programming ASP1 Server Side Programming Database Integration (cont.) Internet Systems Design.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
CIS 451: Using ASP.NET Objects with SQL Dr. Ralph D. Westfall February, 2009.
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.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
CIS 451: ASP.NET Objects Dr. Ralph D. Westfall January, 2009.
1 JavaScript in Context. Server-Side Programming.
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.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
CIS 338: Using Queries in Access as a RecordSource Dr. Ralph D. Westfall May, 2011.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Introduction to JavaScript CS101 Introduction to Computing.
Christopher M. Pascucci.NET Programming CodeBehind.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
CIS 451: Cookies Dr. Ralph D. Westfall February, 2009.
CIS 234: Java Methods Dr. Ralph D. Westfall April, 2010.
1 JavaScript in Context. Server-Side Programming.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Programming with Microsoft Visual Basic th Edition
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
CIS 338: VB Variables Dr. Ralph D. Westfall April, 2011.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
INT213 – WEEK 1 ASP tags and comments Variables, Constants, and "Literals" Simple Output.
Arrays and files BIS1523 – Lecture 15.
Intro to PHP & Variables
Cookies BIS1523 – Lecture 23.
ISC440: Web Programming 2 Server-side Scripting PHP 3
Variables and Arithmetic Operations
MIS 3200 – Unit 5.1 Iteration (looping) Working with List Items
Introduction to JavaScript
Presentation transcript:

CIS 451: ASP.NET Debugging and Server-Side Includes Dr. Ralph D. Westfall February, 2009

Error Handling/Debugging client side vs. server scripts syntax errors logical errors good coding practices to minimize errors testing your code debugging statements

Need to Identify as Server Script code will run on client if doesn't have: <% [code] %> or [code] filetype needs to be.aspx, not.htm(l)

Syntax Errors spelling Reesponse.Write("something") EndIf '2 words: needs a space missing parts of control structures For but no Next If but no End If extra parts for control structures extra Next or extra End If at end

Syntax Errors - 2 using a method as a property Response.Write = "Welcome" don't use = with methods using a property as a method buffer("true") properties are values, so need to use =

Syntax Errors - 3 writing to a "read only" property Dim prices() As Double = {3.00, 2.00} prices.Length = 5 'read only property using Set to create an object Set objMail = _ Server.CreateObject("CDO.Message") 'remove Set (ASP 3.0 still needs Set)

Logical Errors division by a variable that has value of zero if Option Explicit or Strict is not On a = 2 c = a / b 'no value given for b type mismatch e.g. can't do arithmetic with text 5 / "hello" missing period can cause a type mismatch a=CInt(RequestQueryString("card")) 5 / a

Good Coding Practices indent code inside loops and conditionals "pretty listing" (automatic in VS.NET) For intI = 0 to 2 intJ = intI Next I use comments where appropriate 'single quote creates a comment

Good Coding Practices - 2 use Option Strict at start of file forces you to use Dim for all variables helps spot spelling mistakes forces you to handle all type conversions explicitly txtCount.Text=CStr(intCount)

Good Coding Practices - 3 use consistent object naming prefixes btnSubmit 'a button txtLastName 'a textbox for data capitalize function names e.g. conversions CInt(7.3) 'Convert to Integer CCur(9.9) 'Convert to Currency

Good Coding Practices - 4 type checking: is data what you expect? If IsNumeric(Request.Form("num")) Then intTot = intTot + intNum End If type conversion: change data so it is usable intValue = CInt(dblItem1 + dblItem2)

Good Coding Practices - 5 use subprocedures and/or functions for anything substantial (5 or more lines?) that gets done in more than 1 place advantages: shorter program easier to debug and maintain may be able to reuse them in other programs

Good Coding Practices - 6 use "server-side includes" in.aspx filesserver-side includes <% 'prices.aspx file Dim dblProdPrice(11) dblProdPrice(0)=29.99 'etc. %> advantages similar to subprocedures, etc.See Notes Page

Testing Your Code test the different ways a user could go through the application example: shopping cart with 2 catalog pagesshopping cart entry page to catalog page 1 to checkout entry page to catalog page 2 to checkout entry, catalog 1, catalog 2, checkout entry, catalog 2, catalog 1, checkout using browser Back button instead of form button? using link instead of button?

Testing Your Code - 2 test possible data values example: zip codes boundary values (included, or not?) and values in between boundaries to out-of-bounds values negative #s? 6 digit #s? text #s? (ninety thousand and one)

VS Debugging Capabilities break points and icons for stepping through code Step Into, Step Over, Step Out special windows Locals, Output, Watch, View Stack, etc.

Debugging Statements insert "trace" statements to determine values before code where problem is Response.Write([variable name]) use so you can see form input values in query string MsgBox to show specific values

Debugging with "Include" Files some programmers put tracing procedures in separate file add #include file=[trace file name] at top of file being debugged need to then insert calls to trace file procedures in code NET tracing capabilities

More on Server Side Includes special features for HTML files only? extension is.shtml or.shtm so server knows that special processing required #fsize - gives file size #flastmod - gives file last modified date include works in both ASP and HTML # include - includes text (code) from another file so it is processed as if it is in the current file

Server Side Include Issues data is text, so could use.txt as extension can hide file by using.aspx extension Microsoft recommends.inc extension to conveniently identify include files convenient way to keep data in programs up-to-date e.g., put shopping cart product prices data in an include, then update just that file

Using Server Side Includes in ASP.NET need to put "directive" in HTML comments 'path not needed if in current directory can use physical path (address on drive) can also use virtual path (server address)

SSI Exercise view Using Server Side Includes click "basic page," View>Source, edit URLs and Save As basic.shtmlbasic page note: save it as.shtml, not.html also save code for the other linked pages (includes) in same directory modify include files view effects on basic.shtml in browser