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.

Slides:



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

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.
Asp.NET Core Server Controls. Slide 2 Lecture Overview Understanding the types of ASP.NET controls HTML controls ASP.NET (Web) controls.
Anatomy of an ASP.NET Page. Slide 2 My Version of the Big Picture (1) ASP Worker (Engine) Your application Runs Server Other applications User 1User 2.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
 Mark Friedman Architect Developer Division Microsoft Corporation.
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.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 8: WebForms — Web-based.
Web Form Fundamentals MacDonald Ch. 5 MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
OOP and Web Applications Michael Juřek Architect Evangelist Microsoft Corporation.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
INTERNET APPLICATION DEVELOPMENT For More visit:
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.
Chapter 3 Using Validation Controls. What is a Validation Control? A control that validates the value in another control Renders as an HTML tag with an.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Validation Controls. Validation Server Controls These are a special type of Web server control. They significantly reduce some of the work involved in.
.Net is a collection of libraries, templates and services designed to make programming applications of all kinds, easier, more flexible (multi platform),
February 16, Aaron Cuffman Andy Nagle Adam Schultz Web Site.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
ASP.NET and Model View Control Jesper Tørresø ITNET2 F08.
ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JSP Java Server Pages Softsmith Infotech.
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.
CSCI 6962: Server-side Design and Programming Introduction to Java Server Faces.
ASP.NET Controls. Slide 2 Lecture Overview Identify the types of controls supported by ASP.NET and the differences between them.
CSCI 6962: Server-side Design and Programming Introduction to Active Server Pages.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
CSCI 6962: Server-side Design and Programming AJAX Tools in JSF and ASP.
An Introduction to JavaScript Summarized from Chapter 6 of “Web Programming: Building Internet Applications”, 3 rd Edition.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Unit 3: Adding Code to a Microsoft ASP.NET Web Form.
Christopher M. Pascucci Basic Structural Concepts of.NET Managing State & Scope.
Overview of Previous Lesson(s) Over View  SDI programs  The Application Wizard can generate single-document interface (SDI) applications that work.
Server Control Tips & Tricks Presented by: Patrick Hynds Microsoft Regional Director CriticalSites CTO MCSD, MCSE+I, MCDBA, MCSA, MCP+Site Builder, MCT.
JavaServer Faces: Sample App + Life Cycle Compiled from Sun TechDays workshops (JSF Basics, Web-Tier Codecamp: JavaServer Faces, Java Studio Creator)
Anatomy of an ASP.NET Page. Slide 2 Compiling an ASP.NET Page An ASP.NET page is compiled when it is rendered for the first time A page is compiled to.
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.
Beginning ASP.NET (Part 3).NET 2.0 Core Libraries Tuc Goodwin.
BIT 285: ( Web) Application Programming Lecture 06: Thursday, January 22, 2015 Page Object, The Lifetime of a Web Application, Application State and Session.
Introduction to JavaScript CS101 Introduction to Computing.
The Problem of State. We will look at… Sometimes web development is just plain weird! Internet / World Wide Web Aspects of their operation The role of.
ASP.NET 4 Unleashed Chapter 1. .aspx page: contains C# script and HTML code including tags. Listing 1.1 FirstPage.aspx.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
MIS 3200 – Unit 3.2 Page_Load method AutoPostBack property of controls IsPostBack method of the Page object Understanding web page life cycle.
Asp.NET Core Server Controls. Slide 2 Lecture Overview Understanding the types of ASP.NET controls HTML controls ASP.NET (Web) controls.
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.
Event Handling & Viewstate CS 351 Ed Gellenbeck. Today Review of Web Forms ASP.NET Object Hierarchy Events State Management Page State Session State Application.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
Sergey Sidorov PhD student, computer software chair Computer Science department.
ASP.NET Architecture Mike Taulty Developer & Platform Group Microsoft Ltd
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
E-Commerce: Introduction to ASP.Net Application Architecture 1 Dr. Lawrence West, Management Dept., University of Central Florida Topics.
Creating an Interactive Web Page Lesson 2. Objectives.
Intro to JavaServer Faces Mimi Opkins CECS 493 Fall 2016.
Chapter 8 User Controls.
Unit 27 - Web Server Scripting
Anatomy of an ASP.NET Page
Web Development Using ASP .NET
Presentation transcript:

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 the code).  As described initial page requests are relatively simple.  The real work gets done when a page is submitted to itself – and a postback request is generated.  The current value of every control on a Web Form is contained in the postback request. This is referred to as the Post Data.  The content of the ViewState is also contained in the Post Data. ViewState holds the original property values of every control on a Web Form – before the user made any changes.  If a postback was caused, for example, by a button click, Post Data is used to identify the button that caused the postback.

AutoPostBack Property  Along with common events such as click events on buttons, some page elements support postback events for things like selecting items in a list or changing the contents of a textbox.  Since these kinds of “secondary” events can happen quite frequently on a form, these events do not automatically cause event to fire on the server.  Instead you need to add a special attribute to the server control in order to make sure it will create a client-side event that will send a message back to the server for processing.  This special attribute is the AutoPostBack attribute.  In order to force these controls to fire events on the server, you need to set the AutoPostBack attribute to true.

Round Tripping  The web form model supports round - tripping between the client and the server.  In round – tripping, each time the user presses a button, the page is sent to the server, the inputs are interpreted at the server, the page is rebuilt, and then this rebuilt page is sent back to the client again.  This round – tripping continues whenever the user causes a client – side event to fire server side code.  In any Web scenario, web pages are recreated with every round trip.  When the server finishes processing and sends the page to the browser, it discards the page information.

 This frees server resources after each request and a web application can scale to support hundreds or thousands of simultaneous users.  The next time the page is posted, the server starts over in creating and processing it, and for this reason, web pages are said to be stateless.  Stateless means the value of a page’s variables and controls are not saved on the server.

Lifecycle Of a Web Page

Object Initialization  The first stage in page life cycle is initialization.  After the page’s control tree is populated with all the statically declared controls in the.aspx source the Init event is fired.  First, the Init event for the Page Object occurs, then Init event occurs for each control on the Page.  At this point the controls have no attributes or properties.  ViewState information is not available at this stage.

Load ViewState Data  After the Init event, controls can be referenced using their IDs only.  At LoadViewState event, the initialized controls receive their first properties: viewstate information that was persisted back to the server on the last submission.  The page viewstate is managed by ASP.NET and is used to persist information over a page roundtrip to the server.

LoadPostData Processes PostBackData  During this phase of the page creation, form data that was posted to the server (termed postback data) is processed against each control that requires it.  When a page submits a form, the framework will implement the IPostBackDataHandler interface on each control that submitted data.  The page then fires the LoadPostData event and parses through the page to find each control that implements this interface and updates the control state with the correct postback data.

Object Load  Objects take true form during the Load event.  All object are first arranged in the page DOM (called the Control Tree in ASP.NET) and can be referenced easily through code or relative position (crawling the DOM).  If this is the first time the page is being processed (Page.IsPostBack property), initial data binding is performed here.  This stage is where the majority of work happens.  The Load event can be overridden by calling OnLoad.

Raise PostBack Change Events  “Change” events are fired for controls (TextChanged, SelectedIndexChanged, & similar).  The current value (from PostData) is compared to the original value located in the viewState.  If there is a difference “changed” events are raised.

Process Client-Side PostBack event  After the server-side events fire on data that was changed due to postback updates, the object which caused the postback is handled at the RaisePostBackEvent event.  There is often code that will execute in this event, as this is an ideal location to handle event-driven logic.  If validation controls present on the page, server side events are fired for any validation controls.

PreRender the Objects  The point at which the objects are prerendered is the last time changes to the objects can be saved or persisted to viewstate.  This makes the PreRender step a good place to make final modifications, such as changing properties of controls or changing Control Tree structure, without having to worry about ASP.NET making changes to objects based off of database calls or viewstate updates.

ViewState Saved  The viewstate is saved after all changes to the page objects have occurred.  Object state data is persisted in the hidden object.  At the SaveViewState event, values can be saved to the ViewState object, but changes to page controls are not.

Render to HTML  The Render event commences the building of the page by assembling the HTML for output to the browser.  During the Render event, the page calls on the objects to render themselves into HTML.  The page then collects the HTML for delivery.  Changes can still be made at this point, but they are reflected to the client only.

Disposal/Unload  After the page's HTML is rendered, the objects are disposed of.  During the Dispose event, you should destroy any objects or references you have created in building the page.  At this point, all processing has occurred and it is safe to dispose of any remaining objects, including the Page object.