Programming Data-Driven WebSites (ASPX, Active Server Pages) Chris North CS 4604: DB.

Slides:



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

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?
Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
Languages for Dynamic Web Documents
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
1 Chapter 12 Working With Access 2000 on the Internet.
Session 6 Server-side programming - ASP. An ASP page is an HTML page interspersed with server-side code. The.ASP extension instead of.HTM denotes server-side.
Apache Tomcat Server – installation & use Server-side language-- use Java Server Pages Contrast Client-side languages HTML Forms Servers & Server-side.
Multiple Tiers in Action
Performed by:Gidi Getter Svetlana Klinovsky Supervised by:Viktor Kulikov 08/03/2009.
Session Management A290/A590, Fall /25/2014.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
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.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Dynamic Web Sites Chris North cs3724: HCI. Presentations matt ketner, sam altman, mike gordon Vote: UI Hall of Fame/Shame?
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
HTML, GUI, ASP.NET Rina Zviel-Girshin Lecture 2
© 2011 Delmar, Cengage Learning Chapter 9 Collecting Data with Forms.
Server-side Scripting Powering the webs favourite services.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Welcome  30 Question & 30 Minutes  Question Will Move Automatically After 1 Min Your Exam Start Now Lecturer : Zalak Thakrar.
ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
Creating Web Applications Using ASP.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
E-Commerce: Introduction to Web Development 1 Dr. Lawrence West, Management Dept., University of Central Florida Topics What is a Web.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
CS453: State in Web Applications (Part 1) State in General Sessions (esp. in PHP) Prof. Tom Horton.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
1 Accelerated Web Development Course JavaScript and Client side programming Day 2 Rich Roth On The Net
1 Tradedoubler & Mobile Mobile web & app tracking technical overview.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
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.
Caching Chapter 12. Caching For high-performance apps Caching: storing frequently-used items in memory –Accessed more quickly Cached Web Form bypasses:
Chapter 6 Server-side Programming: Java Servlets
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
Global.asax file. Agenda What is Global.asax file How to add the Global.asax file What are the default events available Explanation to Application_Level.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
Dynamic web content HTTP and HTML: Berners-Lee’s Basics.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
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.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
CIS 451: Cookies Dr. Ralph D. Westfall February, 2009.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
Module: Software Engineering of Web Applications Chapter 2: Technologies 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.
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.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Higher Computing Science Coding the Web: HTML, JavaScript, PHP and MySQL.
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
ASP, Databases, and how to stomp project 3 Chris North cs3724: HCI.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 Chapter 22 World Wide Web (HTTP) Chapter 22 World Wide Web (HTTP) Mi-Jung Choi Dept. of Computer Science and Engineering
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
WWW and HTTP King Fahd University of Petroleum & Minerals
PHP / MySQL Introduction
Presentation transcript:

Programming Data-Driven WebSites (ASPX, Active Server Pages) Chris North CS 4604: DB

WinApp vs WebApp Standard client application (WinApp) E.g. C#, Java Single user, location Portability is less critical Power, dynamics Targeted audience Distributed executable Server-side application (WebApp) Broad user class Lightweight, Supports lo-fi clients One-time users, quick, no installation/updates Distributed simultaneous users Simpler functionality, information access Centralized executable, data

Page = Server-side script Dynamically generates page at client request Pulls data from DB to create page contents E.g. E-Bay, Amazon, … Data-Driven WebSites Client (Browser) Server (Web server) URL request html page html Database Table

Sequence 1.User clicks linkhttp://server.com/script.aspx 2.Client requests script.aspx from server.com 3.Server.com executes script.aspx 4.Script.aspx generates html page (using DB data) 5.Server.com sends html page to client 6.Client displays page

Example Books.aspCart.aspPurchase.asp Shows books list Add to cart View cart button Displays cart contents Delete items Purchase button Charges credit card Displays ‘thankyou’ Link back to books Amazon.com server

ASPX Microsoft Active Server Pages,.Net IIS server Old ASP: Html with embedded server scripts Session support Visual Basic script ASPX.Net: Separation of html and code Additional state-preservation capability C# (or any other lang) Visual Studio.net, C# Web Application If install IIS after install VStudio.Net, must run: C:/windows/MS.net/framework/Vx.x/aspnet_regiis.exe -i

ASP = html + script New server-script tags: Tag contents are executed and replaced with script’s output Myscript.asp: The time is Good morning Good afternoon Client receives: The time is 2:03pm Good afternoon At page request, Server executes script Replaced with value of expr Executes code

ASPX: Separate code.aspx = html with asp tags.aspx.cs = associated Csharp code Also supports ASP-style embedded code Env. similar to WinApp, execution different Execution order: 1.Constructor, OnInit (auto-generated code) 2.Page load 3.Any events from form submit request 4.Embedded code in.aspx

Processing Form Input POST (aspx default) Myscript.aspx.cs reads input from Control properties »E.g: ListBox1.SelectedValue GET querystring Myscript.aspx.cs reads input from Request.QueryString »E.g: this.Request.QueryString[“var1”]

Problems Many simultaneous users Who’s who? Request-Response HTTP model (page requests are independent) How to maintain contiguous program state? UI (browser) disconnect from back-end (server) How to keep UI in sync with back-end? (e.g. ‘Back’ button) Books.aspCart.aspPurchase.asp …

Different than GUI programming! Standard WinApp GUI: One user (per executable) ‘Global’ state data Client = server –UI and back-end are same executable Shopping.exe Books window Cart window Purchase window

Solutions in ASPX Provides user ‘session’ awareness (a) Recognizes users by cookies (b) Maintains contiguous state info for each user in global storage. »E.g: this.session[“var1”] (c) Keeps page state info in a hidden form item. »Maintains properties of all UI controls Automatic Who is the user? What is his data? Where is he in the ‘application’?

Form Input & Session State Process form input, store state info: Button1_Click() this.Session(“myname”) = TextBox1.Text; HTML output based on session state: Label1.Text = “Welcome “ + this.Session(“myname”); Or: Welcome, Welcome, chris Enter your name: chris Send

Useful ASPX Objects this. properties:.Session: specific to each user.Application: global, all users.Request:.querystring,.form, ….Response:.redirect,.write, ….Server: utilities.IsPostBack Global.asax events: Session_Start, Session_End Application_Start, Application_End

Database Access The usual connect & query code: OleDbConnection con = new OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:/census4604.mdb"); // Jet=Access OleDbCommand cmd = new OleDbCommand( "SELECT * FROM States4604", con); // SQL query OleDbDataAdapter adpt = new OleDbDataAdapter(cmd); DataSet data = new DataSet( ); adpt.Fill(data); // execute the query and put result in ‘data’

Database Display Binding data to UI controls: ListBox1.DataSource = data.Tables[0]; ListBox1.DataTextField = "Name"; ListBox1.DataValueField = “ID"; ListBox1.DataBind();// always do this to make it finalized DataGrid1.DataSource = data.Tables[0]; DataGrid1.DataBind();// always do this to make it finalized Limited customization capability Can get events Simple coding, similar to WinApp

Database Display Inline scripting: Complete customization, html-level control, more complex code

Database Display Repeater control (combines binding & inline) In file.aspx.cs: Repeater1.DataSource = data.Tables[0]; Repeater1.DataBind(); In file.aspx: Compromise: some customization, some automation

InfoVis tricks on web pages Simple graphics: Image trick: red.gif = 1x1 red pixel gif Control the location (dhtml,xhtml): »places the gif at (100,49) on the page »Z-index -1 means put it behind the page text Control the size (html): »Stretches it into a 75x100 red rectangle Item1 Item2 Item3 Item4 Item5 …

Open Problems: Client-Server Out of Sync ‘Re-post’ problem: E.g: Submit, Back, Submit; purchased twice! Solution: give each form unique ID, counter ‘Jump in too deep’ problem E.g: nav by bookmark deep into app, without logging in. On deep page, check for username, redirect to login page Test page state against session state. Browser cache problem E.g: browser shows old page instead of getting new content Defeat cache using expiration tags

Defeating Browser Cache Expiration tags: <% Response.Expires = -1 Response.Expiresabsolute = Now() - 2 Response.AddHeader "pragma","no-cache" Response.AddHeader "cache-control","private" Response.CacheControl = "no-cache" %> Random queryString: ” > ”

Consistent look-and-feel Banner, Navigation bar, … Server-side ‘include’ files: Put banner, nav bar in separate ‘include’ file: Can be used in.html files too

Document Object Model (more useful in old ASP) <input type=“button” name=“mybutton” value=“OK” onclick=“document.myform.mybutton.color=red”> document myform mybutton … …