COS 381 Day 26. Agenda  Capstone projects are DUE May 10 at 1PM  I will be covering ASP.NET from the handouts  There will be one lecture on Database.

Slides:



Advertisements
Similar presentations
Unit 02. ASP.NET Introduction HTML & Server controls Postbacks Page Lifecycle.
Advertisements

1 Chapter 12 Working With Access 2000 on the Internet.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
Using Visual Basic 6.0 to Create Web-Based Database Applications
COS 381 Day 23. © 2006 Pearson Addison-Wesley. All rights reserved Agenda Capstone progress report Overdue –Only received 1 out of 6 Capstone projects.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
Introduction to ASP.NET
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
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.
Introduction to.Net and ASP.Net Course Introduction Build Your Own ASP.Net Website: Chapter 1 Microsoft ASP.Net Walkthrough: Creating a Basic Web Forms.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
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.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
JavaScript & jQuery the missing manual Chapter 11
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
HTML, GUI, ASP.NET Rina Zviel-Girshin Lecture 2
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
An Introduction to ASP.NET Ed Dunhill blogs.msdn.com/edunhill SLIDE7.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Microsoft Visual Basic 2005: Reloaded Second Edition
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.
10 Adding Interactivity to a Web Site Section 10.1 Define scripting Summarize interactivity design guidelines Identify scripting languages Compare common.
Creating Web Applications Using ASP.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
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.
ASP.NET Controls. Slide 2 Lecture Overview Identify the types of controls supported by ASP.NET and the differences between them.
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.
CSCI 6962: Server-side Design and Programming Introduction to Active Server Pages.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
ASP.NET.. ASP.NET Environment ASP.NET is Microsoft's programming framework that enables the development of Web applications and services. It is an easy.
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.
Website Development with PHP and MySQL Saving Data.
Overview of Previous Lesson(s) Over View  SDI programs  The Application Wizard can generate single-document interface (SDI) applications that work.
Database Handling, Sessions, and AJAX. Post Back ASP.NET Functionality The IsPostBack method in ASP.NET is similar to the BlackBerry.refresh method –IsPostBack.
Module 4: Creating a Microsoft ASP.NET Web Form. Overview Creating Web Forms Using Server Controls.
Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.
ASP.NET 4 Unleashed Chapter 1. .aspx page: contains C# script and HTML code including tags. Listing 1.1 FirstPage.aspx.
1 Final Review. 2 Final Exam  30% of your grade for the course  December 9 at 7:00 p.m., the regular class time  No makeup exam or alternate times.
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
Module 4: Creating a Web Application with Web Forms
Understanding Web Applications Lesson 4. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Web Page Development Understand Web.
Introduction to ASP.NET What is ASP.NET and how is different from ASP –ASP: server side technology for creating dynamic web pages using scripting languages.
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-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Overview of Previous Lesson(s) Over View  ASP is a technology that enables scripts in web pages to be executed by an Internet server.  ASP.NET is a.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
PostBack  When an initial request for a page (a Web Form) is received by ASP.NET, it locates and loads the requested Web Form (and if necessary compiles.
Sergey Sidorov PhD student, computer software chair Computer Science department.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
1 Introducing Web Developer Tools Rapid application development tools ASP.NET-compatible web editors –Visual Studio.NET Professional Edition –Visual Studio.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Section 10.1 Define scripting
Computing with C# and the .NET Framework
Web Application Web Application are programs that can be executed either on a Web server or in a Web browser. An Online store accessed through a browser.
Static and Dynamic Web Pages
Web Development Using ASP .NET
Presentation transcript:

COS 381 Day 26

Agenda  Capstone projects are DUE May 10 at 1PM  I will be covering ASP.NET from the handouts  There will be one lecture on Database access  Quiz 4 on May 4 ASP.NET and Database Access  Assignment 7 (final one) is posted and is Due on May 3 at Midnight Create a complex ASP.NET page ssign7/UMFKorder.aspx ssign7/UMFKorder.aspx

ASP.NET  Where ASP used interpreted languages ASP.NET uses complied languages ASP example (code) ASP example(code) Same in ASP.NET (code) Same in ASP.NET(code)  ASP.NET uses many languages We will use C# Another example (code) Another example(code)

NEW Features of ASP.NET  The following are not part of ASP or any other traditional Web programming languages Server Controls Validation Controls List Controls and Rich Controls HTML Server Controls User and Custom Controls Web Services Integration

Server Controls  Programmable; prepackaged server code program code written to perform dynamic functions Converted to HTML by server Look the same as standard from elements but can be dynamically control by server side code at run-time  Example server controls (code) Example server controls(code)

Validation Controls  Used to validate data users enter into from elements Make a field required Compare against range of inputs Compare two values  Validation controls process data BEFORE a form is submitted

List Controls and Rich Controls  List controls are used to iterate, process and display dynamic data Database query Program array  Rich controls are complex components Calendar Ad Rotator

HTML Server Controls  Same as HTML elements except runat=“server”  Example (code) Example(code)

User and Custom Controls  User Controls Mini-ASP.NET pages Included in other ASP.NET pages  Custom Controls Written entirely in another language like  C++, C# VB Precompiled and added to ASP.NET

Web Service Integration  Small Programs to which you can call functions and get results  Transfer data using XML over HTTP  AN Example US Postal Service has web service to output all ZIP Codes In order to include ZIP Codes in your ASP.NET application you simply poll the USPS Web Service

Web Service HTTP Response HTTP Request Client PC Webserver SOAP- Capable Browser Web Service -- Interface Properties Methods SOAP Message Using XML Syntax Web Service

Similarities to ASP  ASP pages coexist with ASP.NET Cannot share session information  Still have Response and Request objects All info requested with a web page  Form data  Query Strings All info returned with a webpage

Components of.NET  3 major parts Common language runtime (CLR)  A virtual machine that runs all.NET programs  Run-time language is Microsoft Intermediate language (MSIL)  Uses JIT Compilation Common type system (CTS)  Standard set of types Value types (int, char…) Reference types for objects  Common naming convention (CLS) Class Library  Predefined code packaged as classes  All.NET classes or part of System namespace

Class Libraries  Namespaces Hierarchical naming convention Matches class inheritance tree  Common Namespaces in.NET System root namspace System.data System.xml System.net System.security System.web

Writing C# code in.NET  Object oriented Class  public class Car { } Object  Car c = new Car(): Member variable  private int Gas; Method  private void Drive() {} Property  Public int Gasoline { get {return Gas; } set {Gas=value;}} Overloading  Method with different parameter list Inheritance  The power of OOP

Getting Started with.NET  Installing.NET Need.NET SDK  Loaded with Visual Studio.NET  Available under MSDNAA Need IIS  Personal edition or Server Microsoft Data Access Components (MDAC)  For data base access Service packs and updates

.NET Framework SDK  Assemblies ASP.NET pages Executed in CLR  Metadata Data about data Provides location of class definitions. How to load classes and any defines attributes  Global Assembly Cache Centralized locations for assemblies

Working with Dreamweaver  Chapter 3 of text provides a good overview Only issue is that it assumes that you have a web server available on your Desktop..we do in N-105. You may not have on your home computer

Setting up Dreamweaver MX to Create ASP.NET Applications  Open Dreamweaver MX.  Select Site > New Site… from the Menu bar to create a new site.  On the Basic tab, enter the following information, clicking Next at the bottom of each screen: Name: MyASPNET Yes, I want to use a server technology.  Select ASP.NET C# as the server technology. Edit and then upload to remote testing server, storing your files at H:\asp. URL to browse to the root of your site name”. No, do not copy files when I am done editing.  Click Done to create an initial cache of your site.  Lets do this “Step by Step”

Web Form Controls  Learn by doing Create new ASP.NET C# page

Insert new Form Element

Set to Run at Server

Add Label Control

Web Form  Save and test previous example  Go to “View Source”

Building Dynamic Pages  Update page based on external conditions  runat=“server” means that a control can be manipulated  Let’s modify our page to display an user input ADD asp:textbox ADD asp:button

Then we add a Page Load Function Change Function text

About Post Back  Form “post’ back to themselves No need to reload form Makes the form interactive  isPostBack is true when Something control has caused the form to be to be sent to the server and the form is “reloaded”  Problem is that you allways return to the same form page

Form vs Query Srting  In CGI programming we used the Query String to collect data from a form and pass it to our script Uses method=“get” Security/performance issue  In ASP.Net We use the action=“post” and read our values from the response object  Response.Form[“txtFirstName”] We use get when we want to load a different page and pass data to the page  stuff

Using Request.Form Add Text

Examples ASP.NET  All examples from class are at SPdotNet/script.htm SPdotNet/script.htm  Today’s Example (so far) WebForm1 (code) WebForm1(code)

Moving between pages  Since Web Form Post Back ….how do you go to another web Page? Response.Redirect(“Url”);  If you don’t want to finish processing the page you are on Response.Redirect(“Url”, true);  The hidden form element __VIEWSTATE gets lost

Session Variables  To move data between different Web forms you can use Session Variables To Set a Session Variable (original Web Form  Session[“aVariable”] = “some data”; To get a Session Variable (second Web Form)  lblSomeLable.Text = Session[“aVariable”].ToString();  String str = Session[“aVariable”].ToString(); Example (code1) (Code2) Example (code1) (Code2)

Working With Drop-Down Lists  To add a Drop Down use Dreamweaver’s wizard

Drop Down List  Coding Drop Downs In Body section List Item 1 To add a item dynamically dblSampleList.Items.Add("List Item 2"); dblSampleList.Items.Add("List Item 3"); Example (code) Example(code)

Binding Data  Used for binding data from a Database or an array to a controls at run time Another way to add list items Bind values to variables  Two Styles for Binding Data exist  Textbook Error References to BindData() should be change to DataBind()

Binding Data  First Style  In body of HTML  Type in or use ASP.NET Bound Data Icon in Dreamweaver  Must call Page.DataBind(); in Page_load function (note error in text book!)  Will be replaced by value of variable  Second Style

Binding Data  Second Style In Page_Load Function  someList.DataSource = someList;  Page.DataBind();  Example (code) Example (code)

Event Handling in ASP.NET  Events are messages sent out by objects Different objects – Different messages  In ASP.NET events occur when the server detects an event page-Level events  Occur when users visits a web page Control events  Occur when a user manipulates an ASP.NET control

Page Events  Web Form trigger 11 events when loaded (in order) 1. Initialization (Page_Init) 2. Load View State 3. Post Back Data Processing 4. Page Load (Page_Load) 5. Post Back Change Notification 6. Post Back Event Processing 7. Pre-rendering (Page_PreRender) 8. Same view State 9. Rendering 10. Disposing 11. Unload

Page Level Events  These events do not need to be registered  Most common Used Page Event is Page_Load protected void Page_Load(Object Src, EventArgs E) { if (!PostBack) DataBind(); }  Example (code) Example(code)

Control Events  Must have registered Handlers Use Delegates which listen for events and then delegating responsibility for the event to the assigned handler Generally event handlers (like Page_Load) have two parameters  Object src The object which created the event  EventArgs E Specific information about the event

Creating a handler for a ASP.NET Control  ASP.NET Control must be in a Web Form that is set to runat=‘server”  Use Dreamweaver Wizard

Control Events  The Dreamweaver wizard will register the event but you still need to write the handler code Between tags in Head void btnTest_OnClick( Object Src, EventsArgs E) { Some C# code } ExampleExample (Code)(Code)

Adding Controls and Events Programmatically  Between tags in head Button btnTest = new Button(); btnTest.Text = “daButton”; btnTest.Click += new EventHandler(this.btnTest_OnClick); samePanel.Controls.Add(“btnTest”); Make sure you write the btnTest_Onclick functions  Example (code) Example(code)

Complex Controls  Have lots of functionality; sometimes called rich controls  We will look at two complex controls Ad Rotator File upload  You can create your own Complex Controls (chap 10 & 11 in text)

AD Rotator  Places Different images in your Web Form every time someone loads the page. Images are licked to a web site 3 Parts  Images  The ASP.NET Ad Rotator Control  A XML configuration file Example (Code) Example(Code)

XML config File  *.jpg URL text 50 Macromedia *.jpg UrL Text 30 Microsoft example

Adding The Ad Rotator Control  Use Dreamweaver wizard More tags icon Under ASP.NET tags use asp:adrotatoor

Web Form Validation  Input fields need to be checked Check for errors before using the data in a program or putting into a database We can check for  Existence  Format  Range of vales  Data type  ASP.NET includes validation controls that automatically provide form field validation with little or no extra coding

Preprogrammed Validators  Does both client side and server side validation of data DHTML  CSS  JavaScript  ASP.NET includes 5 preprogrammed Validators Required field Range Compare Regular expression Custom

Adding a Required field validator  Must use a Web Form that runat=‘server”

Adding a Validation summary  This is a place for all the validation errors to appear ExampleExample (code)(code)

Value Based Validators  Required Text Validators only require that some text is entered but you may want to check to actual text entered Compare against  Value (compare validator)  Type (compare validator)  Another control (compare validator)  A regular expression (regular expression validator)  A range of values (range validator)  Other conditions (custom validator)

Adding value Validators

Regular Expression  Same as JavaScript and Perl \w is alpha char \d is decimal char * zero or more + one or more ? Zero or one. Matches any character except newline [] range of characters [A-Z] upper case \* matches *  Matches s

Validations examples  Compare, Range & Regular expression Example (code) Example(code)  Custom validator Example (code) Example(code)  Assignment #7