Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)

Slides:



Advertisements
Similar presentations
Mark Dixon Page 1 16 – Passing Data between pages: Forms, Sessions, & Query Strings.
Advertisements

Languages for Dynamic Web Documents
Mark Dixon Page 1 17 – Persistent data storage: relational databases and ADO.
Server-Side vs. Client-Side Scripting Languages
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.
1 Today: Introduction to ASP- Part 1 Explain the client/server architecture Explain Web-based client/server applications Understand the essentials of Active.
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: HTML and Client-side code.
Mark Dixon Page 1 02 – Dynamic HTML (client-side scripting)
Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)
Mark Dixon, SoCCE SOFT 131Page 1 16 – Web applications: HTML and Client-side code.
Introduction to Active Server Pages
Mark Dixon, SoCCE SOFT 131Page 1 16 – Passing Data between pages: Sessions, Query Strings, & Self Posting.
Mark Dixon Page 1 02 – Queries: Query by Example.
1 Software Testing and Quality Assurance Lecture 32 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
Mark Dixon Page 1 20 – Web applications: Writing data to Databases using ASP.
Mark Dixon, SoCCE SOFT 131Page 1 19 – Web applications: Server-side code (ASP)
Mark Dixon, SoCCE SOFT 131Page 1 08 – Web applications: HTML and ActiveX controls.
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: Writing data to Databases using ASP.
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
MSSQL & ASP. Client-Server Relationship Client-Server Relationship HTML Basics HTML Basics Scripting Basics Scripting Basics Examples Examples.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Mark Dixon Page 1 19 – Passing Data between pages: Forms, Sessions, & Query Strings.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
ASP.NET Dr. Ralph Westfall May, Web Development Problem HTML designed to display static pages only interactive when user clicks links  can’t provide.
M Dixon 1 Web-Application Development Workshop. M Dixon 2 Session Aims & Objectives Aims –to introduce the main concepts involved in creating web-applications.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
Mark Dixon Page 1 3 – Web applications: Server-side code (JSP)
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Mark Dixon 1 22 – Web applications: Writing data to Databases using ASP.Net.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using ASP.
Creating Databases for Web Applications cookie examples lab time: favorites cookies & Sessions class time for group work/questions on projects Next class:
Mark Dixon 1 18 – Web applications: Server-side code (ASP.Net)
Mark Dixon Page 1 18 – Web applications: Server-side code (ASP)
Mark Dixon, SoCCE SOFT 131Page 1 02 – Dynamic HTML (client-side scripting)
Mark Dixon Page 1 18 – Web applications: Server-side code (PhP)
ASP/ASP.NET: Tricks and Tips How to get Microsoft’s Programming Language to work for you By Wade Tripp Park University
Mark Dixon 1 03 – Passing Data between pages: Forms, Sessions, & Query Strings.
Lecture Note 1: Getting Started With ASP.  Introduction to ASP  Introduction to ASP An ASP file can contain text, HTML tags and scripts. Scripts in.
Mark Dixon Page 1 Web-Application Development Workshop.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP.
Mark Dixon, SoCCE SOFT 131Page 1 24 – Datatypes and Object Association.
M Dixon 1 Web-Application Development Workshop. M Dixon 2 Session Aims & Objectives Aims –to introduce the main concepts involved in creating web-applications.
Mark Dixon 1 19 – Passing Data between pages: Forms, Sessions, & Query Strings.
Mark Dixon, SoCCE SOFT 131Page 1 02 – Dynamic HTML (client-side scripting)
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
M Dixon 1 Tech HTML. M Dixon 2 Admin Attendance Register: –log in to your profile.
Mark Dixon Page 1 Tech – HTML. Mark Dixon Page 2 Admin Attendance Register: –log in to your profile.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
Scripting Languages Client Side and Server Side. Examples of client side/server side Examples of client-side side include: JavaScript Jquery (uses a JavaScript.
Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
PHP Form Processing * referenced from
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
9 – Web applications: Server-side code (ASP)
Introduction to ASP By “FlyingBono” 2009_01 By FlyingBono 2009_01
21 – Web applications: Server-side code (ASP)
18 – Web applications: Server-side code (PhP)
18 – Web applications: Server-side code (ASP)
12 – Passing Data between pages: Forms, Sessions, & Query Strings
PHP / MySQL Introduction
17 – Persistent data storage: relational databases and ADO
Introduction to JavaScript
Presentation transcript:

Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)

Mark Dixon Page 2 Session Aims & Objectives Aims –To introduce the fundamental ideas involved in server-side code Objectives, by end of this week’s sessions, you should be able to: –create an asp web-page, including: HTML, and server-side VB script

Mark Dixon Page 3 Example: Logon page Logon pages – probably most common page –hotmail –Amazon –University portal –utility bills (gas, electricity, phone, internet) –Travel (flights, ferry, car rental)

Mark Dixon Page 4 Example: Logon Restrict access to home page

Mark Dixon Page 5 Example: Logon - code (v1) Using Client-side VB Script: Sub btnLogon_OnClick() If txtUserName.value = "mark" And txtPassWord.value = "soft131" Then window.navigate "Home.htm" Else window.navigate "LoginFail.htm" End If End Sub Please logon: Logon.htm My Home page Welcome to my home page. Home.htm Sorry, those login details were incorrect. Please try again LoginFail.htm

Mark Dixon Page 6 Problem: View Source View Source – shows client-side script: Reveals both username & password

Mark Dixon Page 7 network connection Web Hardware and Software Client Server Browser Application (MS Explorer, Netscape) Web-server Application (MS IIS, Apache)

Mark Dixon Page 8 Request-Response Cycle: HTML Browser Application (MS Explorer, Netscape) Web-server Application (MS IIS, Apache) Request Mark Dixon's web site Mark Dixon's web site Welcome to my web server. Please select from the following list: Soft131: Introduction to programming for Multimedia and Internet applications. Response

Mark Dixon Page 9 Request-Response Cycle: CSC Browser Application (MS Explorer, Netscape) Web-server Application (MS IIS, Apache) Logon.htm Request Sub btnLogon_OnClick() If txtUserName.value = "mark" And txtPassWord.value = "soft131" Then window.navigate "Home.htm" Else window.navigate "LoginFail.htm" End If End Sub Please logon: Response Client-side code: Code sent to Client Interpreted by browser

Mark Dixon Page 10 Request-Response Cycle: SSC Browser Application (MS Explorer, Netscape) Web-server Application (MS IIS, Apache) Request Today's date The date today is 21/11/2005 The time is currently 10:28:18 Response Today's date The date today is <% Response.Write(Format(Now, "D")) %> The time is currently <% Response.Write(Format(Now, "T")) %> Server-side code: Interpreted by server (code never sent to Client)

Mark Dixon Page 11 Server-side Script (what) ASP – active server pages –executed on server takes time – request-response cycle requires server software (e.g. IIS) –code not sent to client code secure (can't be viewed by client) –results (response) sent to client pages will NOT work by double clicking on file

Mark Dixon Page 12 Server-side Script (how) ASP code: –.aspx (not.htm) –between –Response object: page sent back to client write method: adds text to response object –Now object: current date (server) Today's date The date today is <% Response.Write(Format(Now, "D")) %> The time is currently <% Response.Write(Format(Now, "T")) %> Date.aspx

Mark Dixon Page 13 Form Submission action attribute submit button Login Please login: Username: Password: Login.htm

Mark Dixon Page 14 Form Processing Login <% If Request.Form("txtUserName") = "George" Then Response.Write "Login successful." Else Response.Write( "Invalid user name.") End If %> Login.aspx

Mark Dixon Page 15 View Source Code executed at server –code is never sent to client View, Source – does not show code:

Mark Dixon Page 16 Code Execution Login <% If Request.Form("txtUserName") = "George" Then Response.Write("Login successful.") Else Response.Write("Invalid user name.") End If %> LoginCheck.aspx Server SW (IIS) Login Invalid user name. Response

Mark Dixon Page 17 Example: Logon - code (v2) Using Server-side VB Script: Please logon: Logon.htm <% If Request.Form("txtUserName") = "mark" And Request.Form("txtPassWord") = "soft131" Then Response.Redirect("home.htm") End If %> Sorry, those login details were incorrect. Please try again Login.aspx My Home page Welcome to my home page. Home.htm

Mark Dixon Page 18 Running your ASP page within Visual Studio –Run (play) button (F5) –only available to you on development PC using Internet Information Services (IIS) –makes PC a server –page available to all computers on internet

Mark Dixon Page 19 IIS - Installing IIS / personal web server on Windows CD Start, Settings, Control Panel, Add/Remove Programs Add/Remove Windows Components IIS

Mark Dixon Page 20 IIS: Enabling/Disabling Start, Settings, Control Panel, Administrative Tools, Internet Services Manager Stop Start

Mark Dixon Page 21 IIS: Exposing pages Put ASP pages in: –C:\INetPub\wwwRoot (this part of hard disk exposed to outside world) Execute pages by putting: –localhost (in web browser, e.g. IE, means local machine) ASP pages don't work by double-clicking

Mark Dixon Page 22 IIS – Date.asp localhost/test/date.aspx C:\INetPub\wwwRoot\Date.aspx

Mark Dixon Page 23 Reference: Server Object Model Request object: calling web page –Form: used to get form data from previous page Response object: web page sent back –Write: used to put text into web page –Redirect: used to navigate to other page –Clear: erases all HTML in web page

Mark Dixon Page 24 Client-side vs. Server-side Code Sub btnLogon_OnClick() If txtUserName.value = "mark" And txtPassWord.value = "soft131" Then window.navigate "Home.htm" Else window.navigate "LoginFail.htm" End If End Sub Please logon: Logon.htm <% If Request.Form("txtUserName") = "mark" And Request.Form("txtPassWord") = "soft131" Then Response.Redirect("home.htm") End If %> Sorry, those login details were incorrect. Please try again LoginFail.aspx Both use VB Script language (i.e. Sub, If, Dim, For, etc.) Objects are different

Mark Dixon Page 25 Data Types Variant – all types of data –slow, memory hungry Boolean – true or false Integer – whole numbers ( to 32768) Long – whole numbers (large) Single – decimal numbers Double – decimal numbers (more precise) String – text Object – object instances

Mark Dixon Page 26 Data Type Selection Number ofe.g. 4 Integer/Long Rooms Heighte.g. 1.87m Single/Double Surnamee.g. Smith String Car Rege.g. XY55 ABC String

Mark Dixon Page 27 Using data types Variable declaration Dim x As Long Parameters Sub Thing(boo As String, y As Long) Functions Function IsTall() As Boolean

Mark Dixon Page 28 client-side vs. server-side code client-side code – only variant server-side code – all data types Dim x Dim y Dim s Dim b x = 23 y = 18.5 s = "Hello there" b = false Dim x As Long Dim y As Double Dim s As String Dim b As Boolean x = 23 y = 18.5 s = "Hello there" b = false

Mark Dixon Page 29 Example: Apples Apples How many apples do you want? Apples Here are your apples: <% Dim s As String Dim i As Long Dim a As Long a = Request.Form("txtApples") s = "" For i = 1 To a s = s & " " Next Response.Write(s) %> Apples.htm Apples.aspx

Mark Dixon Page 30 Tutorial Exercise: Login LEARNING OBJECTIVE: create an ASP page, including HTML and server-side VB Script Task 1: Get the Login (v2) example from the lecture working. Task 2: Use view source – you should not be able to see the code.

Mark Dixon Page 31 Tutorial Exercise: Date LEARNING OBJECTIVE: create an ASP page, including HTML and server-side VB Script Task 1: Get the Date example from the lecture working. Task 2: Add code that displays good morning/afternoon/evening/night, depending on the time of day.

Mark Dixon Page 32 Tutorial Exercise: Apples LEARNING OBJECTIVE: use variables with specific data types in ASP code Task 1: Get the apples example (from the lecture) working. Task 2: Modify your program so that the user enters another number, and the code adds a new line tag for that number of apples. Hint: Within the loop divide the number of apples by the second number, if the result is a whole number add a new line tag.

Mark Dixon Page 33 Tutorial Exercise: Student Loan LEARNING OBJECTIVE: create an ASP page, including HTML and server-side VB Script from scratch to solve a problem Task 1: Create a web site that allows the user to enter their salary and the computer calculates the annual and monthly payments for their student loan. Hint: You will need 2 pages (1 HTML with a form, linked to another ASPX file with code to do the calculation and display the result) Go to the student loans web-site to get the rules for repayment.