Web Application Development Vijayan Sugumaran Decision and Information Sciences Oakland University.

Slides:



Advertisements
Similar presentations
E-Commerce CMM503 – Lecture 8 Stuart Watt Room C2.
Advertisements

HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Lecture 6/2/12. Forms and PHP The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input When dealing with HTML forms.
The Web Warrior Guide to Web Design Technologies
CIS101 Introduction to Computing Week 08. Agenda Your questions JavaScript text Resume project HTML Project Six This week online Next class.
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Chapter 31 Basic Form-Processing Techniques JavaServer Pages By Xue Bai.
1 Chapter 12 Working With Access 2000 on the Internet.
JavaScript Forms Form Validation Cookies CGI Programs.
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.
Python and Web Programming
USER INTERACTIONS: FORMS
Creating Web Page Forms
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
JAVASCRIPT HOW TO PROGRAM -2 DR. JOHN P. ABRAHAM UTPA.
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.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
Web forms in PHP Forms Recap  Way of allowing user interaction  Allows users to input data that can then be processed by a program / stored in a back-end.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
CO1552 Web Application Development HTML Forms. Websites can be made more interactive by providing facilities for users to provide data To get user entered.
INTERNET APPLICATION DEVELOPMENT For More visit:
Forms and Form Controls Chapter What is a Form?
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
JavaScript, Fourth Edition
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
CIS 451: ASP.NET Objects Dr. Ralph D. Westfall January, 2009.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
Website Development with PHP and MySQL Saving Data.
HTML Forms.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
ITCS373: Internet Technology Lecture 5: More HTML.
XHTML & Forms. PHP and the WWW PHP and HTML forms – Forms are the main way users can interact with your PHP scrip Typical usage of the form tag in HTML.
7 Chapter Seven Client-side Scripts. 7 Chapter Objectives Create HTML forms Learn about client-side scripting languages Create a client-side script using.
Microsoft FrontPage 2003 Illustrated Complete Creating a Form.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
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.
Web Page Design Forms! Website Design. Objectives What forms can do The Attributes of the form tag Using Textboxes Textareas Checkboxes Radio buttons.
Copyright © Texas Education Agency, All rights reserved.1 Web Technologies Website Forms / Data Acquisition.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP (COMPONENTS) Active Server Pages (cont..) 1. global.asa file The Global.asa file is an optional file that can contain declarations of objects, variables,
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Project 6: Creating XHTML Forms Kelly.
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Lesson 5 Introduction to HTML Forms. Lesson 5 Forms A form is an area that can contain form elements. Form elements are elements that allow the user to.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Lecture 6 Sara Almudauh ASP.NET Part 1 Development of Internet Application 1501CT - Sara Almudauh.
ASP Explained By: Sarbjit Kaur.
Introducing Forms.
The Request & Response object
ASP.
Client side & Server side scripting
Browser and Server Models
Forms, cont’d.
Presentation transcript:

Web Application Development Vijayan Sugumaran Decision and Information Sciences Oakland University

Agenda Session 1 – Introduction to ASP –Assignment #1 Session 2 – Database Connectivity –Assignment #2 Session 3 – ASP Application Development –Assignment #3

Introduction to ASP Session 1

Forms provide a way for a web page to interact with a user Generating a static web page does not begin to tap into the unlimited possibilities the internet has to offer By using forms we can gather information and make decisions Why Use Forms in a Web Site?

Server side scripting environment ASP script begins to run when a browser requests an.asp file from the web server Web server then executes the commands Generate response and send an html page to the browser Active Server Pages

Creating ASP Files –Microsoft FrontPage –Visual InterDev –Any HTML editor and add scripts later Viewing ASP pages –ASP page has to be executed on the server –Can’t just view the page on the client –Server running (IIS4.0/Personal Web Server4.0) –To force the server to execute the ASP page, place it in the required/suitable directory Creating and Viewing ASP Pages

A form is encapsulated with the tags A web form is similar to a paper form. A form can contain many elements: –Text Fields –Checkboxes –Droplists –Radio Buttons Each of these items are called “form controls” They are described using a “label” The following controls are generated using these tags: –Textbox = –Textbox = –Checkbox = –Checkbox = –Radio Buttons = –Radio Buttons = –Lists = a tag followed by one or more tags Form Elements

An Example Form Generally, a form is created with an embedded table. The table helps align the information. The form controls are placed within each cell of the table. Red dotted lines designate the borders of the form Black dotted lines designate the borders of the table Text box control Drop list control

Request For Information First Name Last Name Address Partial code for previous form Form tag and name Form control that allows a customer to enter their first name CSS Class for this control Name of the control Determines how the form data is sent to the server When the submit button is clicked, the function is executed first and then the action, i.e., calling the asp page Name of the controls

Radio buttons are mutually exclusive (i.e. only one can be selected at a time) Submit buttons are used to submit the information to the server –When the customer clicks the submit button an action is performed and a method is executed –On the previous slide, the action was shown to be register.asp and the method is GET Form Elements Notes

After the customer clicks on the submit button the following information can be found in the address bar of the browser: =cavaliere& _address=&street=&city=&state=AL&zipcode=&cust_intrest=1& Submit=Submit Information after the question mark informs the server that the URL includes URL Encoded Data, i.e., QueryString Data Sending Form Data to Server

Each occurance of name=value is called a name-value pair. =cavaliere& _address=&street=&city=&state=AL&zipcode=&cust_intrest=1& Submit=Submit Each name is the name of the attribute of a form control (last_name) and the value is the value returned by the control (cavaliere) Each value pair concatenated with “&” QueryString

There are two ways to package data to send it to the server –Post Requests are sent all the way to the specified server This is important for an e-commerce site where you want to view fresh information after saving items to a shopping cart –Get Requests are cached by an intermediate server Instead of getting a fresh page, we might receive a copy of the page viewed previously Allows requests to be satisfied without needing to send the request all the way back to the original server and the response all the way back to the requesting browser Sending Data to Server

The register.asp page is used to process the data when the submit button is clicked.asp designates a web page that is written using ASP ASP code is enclosed in tags Processing the Data on the Server

<% Dim strFirstName, strLastName, strStreet, strCity, strState, str , strCustIntrest strFirstName = request.querystring("cust_name") strLastName = request.querystring("last_name") strStreet = request.querystring("street") strCity = request.querystring("city") strState = request.querystring("zipcode") strCustIntrest = request.querystring("cust_intrest") str = request.querystring(" _address") %> <% Response.Write("Thank you " & strFirstName & " for your request.") %> <% if strCustIntrest = "1" then Response.Write("We will the information to you at " & str & " ") else Response.Write("We will send the information to you at your home address") end if %> Requst.querysting is used to extract the data being sent to the server Visual Basic is used to generate conditional output (Javascript could also be used) Lines in green are displayed on the resultant web page. Notice how HTML tags are embedded into the output Sample ASP Code

Forms are used to gather information from a customer Forms use the tags Tables are used to layout the form-controls on the page When the user clicks on the submit button, the information is sent to a server where it is processed (in this case by an ASP page) Putting it all together

Client Server Response Object Request Object ObjectContext Object Server Object Session Object Application Object ASP Object Model

Request Object –Captures all the information about user’s request Response Object –Send information back to the user –Server’s response to the user ObjctContext Object –Used to either commit or abort transactions managed by Microsoft Transaction Server initiated by an Active Server Page script. ASP Objects

Server Object –Represents the environment in which ASP pages run –Provides general utility functions Application Object –An application can contain a set of script files, html documents, images, etc. –Represents an entire Active Server Pages application Session Object –Store information about a user session –A session object maintained for each user –Values stored in the session object are not discarded when the user jumps between pages. ASP Objects

User’s request info is stored in collections Collections –QueryString – Values of variables in the HTTP query string –Form – values of form elements sent from the browser –ServerVariables – Values of the HTTP and environment variables –Cookies – Values of cookies sent from the browser –ClientCertificate – client certificate values sent from the browser Properties –TotalBytes – Specifies the number of bytes the client is sending in the body of this request Methods –BinaryRead – used to retrieve data sent to the server as part of the POST request Request Object

Collections –Cookies Properties –Buffer –CacheControl –Charset –ContentType –Expires –ExpiresAbsolute –IsClientConnected –PICS –Status Methods Methods  AddHeader  AppendToLog  BinaryWrite  Clear  End  Flush  Redirect  Write Response Object

Collections –None Properties –ScriptTimeout – Length of time a script can run before an error occurs Methods –CreateObject – Creates an instance of an object or server component –HTMLEncode – Applies HTML encoding to the specified string –MapPath – Converts a virtual path to a physical path –URLEncode – Applies URL encoding including escape chars to a string Server Object

Collections –Contents – contains all items added to the session through script commands –StaticObjects – contains all objects added to the session with the tag Properties –CodePage – Sets the codepage used for symbol mapping –LCID – sets the locale identifier –SessionID – returns the session identification for this user –Timeout – sets timeout period for session state for application Methods –Abandon – destroy a session object and release the resources Events –onStart – occurs when the server creates a new session –onEnd – occurs when a session is abandoned or times out Session Object

Caution You cannot view the ASP source code by selecting "View source" in a browser You will only see the output from the ASP file, which is plain HTML This is because the scripts are executed on the server before the result is sent back to the browser.

Writing Back to Client… The Write method of the ASP Response Object is used to send content to the browser. For example, the following statement sends the text "Hello World" to the browser: You may use different scripting languages in ASP files. However, the default scripting language is VBScript: To set JavaScript as the default scripting language for a particular page you must insert a language specification at the top of the page:

Procedures and Functions The ASP source code can contain procedures and functions: <% sub vbproc(num1,num2) response.write(num1*num2) end sub %> Result:

Procedures and Functions Insert the line above the tag to write procedures or functions in another scripting language than default: <% function jsproc(num1,num2) { Response.Write(num1*num2) } %> Result:

User Input The Request object may be used to retrieve user information from forms Two ways: –Request.QueryString –Request.Form Consider this form definition First Name: Last Name:

Request.QueryString Request.QueryString command is used to collect values in a form with method="get". Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) Has limits on the amount of information to be sent Welcome <% response.write(request.querystring("fname")) response.write(" " & request.querystring("lname")) %>

Request.Form Request.Form command is used to collect values in a form with method="post". Information sent from a form with the POST method is invisible to others Has no limits on the amount of information that could be sent Welcome <% response.write(request.form("fname")) response.write(" " & request.form("lname")) %>

Text Field Example Sending the form data Calling the ASP page to process the data Get the value of the form element called “name” Get the value of the form element called “ ” Try Form Example

Radio Button Example Call an ASP Page using the POST method Creating a text field Set of Radio Buttons Notice: a)All the buttons have same name b)First button is checked by default Submit Button

Radio Button Example (Continued) Creating a variable (TheName) and assigning a value to it Retrieving the value of the form element named “COLOR” (set of Radio buttons) Depending upon which radio button was clicked on, the variable “colornumber” will have the “value” of that radio button Use if statement to printout the appropriate message Try This Example

Drop-down List Example (hellocolor.htm) Chose a color Saying Hello in Different Colors Here are the available colors: Choose a color Red Green Blue Orange Pink How many times? Creating a drop-down box named “definedcolor”

Drop-down List Example (hellocolor.asp) Name and Color <% TheColor = Request.form("definedcolor") TheCount = Request.form("count") %> <% if Thecolor = "Red" then For mycount = 1 to TheCount %> Hello <% elseif Thecolor= "Blue" then For mycount = 1 to TheCount %> Hello <% elseif Thecolor= "Green" then For mycount = 1 to TheCount %> Hello <% elseif Thecolor= "Pink" then For mycount = 1 to TheCount %> Hello <% elseif Thecolor= "Orange" then For mycount = 1 to TheCount %> Hello <% else For mycount = 1 to TheCount %> Hello Try This Example Get the value of selected color and store it in a variable Get the value of count as well Nested If.. Elseif.. Else statement to check the color and display “Hello” Notice the For.. Next loop.

Checkbox Example (checkbox.htm) Please indicate the albums that you would like: <input type=checkbox name="album" value="No Way Out (Puff Daddy)">No Way Out (Puff Daddy) <input type=checkbox name="album" value="Secrets (Tony Braxton)">Secrets (Tony Braxton) <input type=checkbox name="album" value="Release Some Tension (SWV)">Release Some Tension (SWV) <input type=checkbox name="album" value="When Disaster Strikes (Busta Rhymes)">When Disaster Strikes (Busta Rhymes) <input type=checkbox name="album" value="My Way (Usher)">My Way (Usher) &nbsp Creating a series of checkboxes named “album” Calling the asp page checkbox.asp

Checkbox Example (checkbox.asp) Process Order Here are the albums you selected <% selected_albums = Request.form("album") Dim album_Array album_Array = split(selected_albums, ",") Dim iLoop For iLoop = LBound(album_Array) to UBound(album_Array) Response.write album_Array(iLoop) & " " Next %> Try This Example Get all the selected album names in one long string separated by comma Separate the names using the “split” function and store the names in the array Loop through the array and print the value stored in each element of the array on a separate line using “ ”

Assignment #1 Create an HTML form with text fields, Checkboxes and radio buttons The form should also contain a submit and a reset button When the form is submitted, it should call an asp page, which summarizes the data that the user entered. Exercise#1 - Word Document See Solution