asp net page life cycle
Download
Skip this Video
Download Presentation
ASP.NET Page Life Cycle

Loading in 2 Seconds...

play fullscreen
1 / 38

ASP Page Life Cycle - PowerPoint PPT Presentation


  • 209 Views
  • Uploaded on

ASP.NET Page Life Cycle. Dev Basics Series Jay Harris. About the Talk. Covers. Life Cycle Data Binding Tips & Tricks Pain Points. Overview. What to expect out of this session. Discuss: ASP.NET Page Life Cycle Proper use of Data Binding Events

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'ASP Page Life Cycle' - Pat_Xavi


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
asp net page life cycle

ASP.NET Page Life Cycle

Dev Basics Series

Jay Harris

overview

About the Talk

Covers

Life Cycle

Data Binding

Tips & Tricks

Pain Points

Overview

What to expect out of this session

Discuss:ASP.NET Page Life CycleProper use of Data Binding Events

Involves only ASP.NET EventsNo MVC. No Silverlight.No Controls or DataSource Controls

Tips & Tricks. And Traps.

overview3

About the Speaker

Covers

Life Cycle

Data Binding

Tips & Tricks

Pain Points

Overview

What to expect out of this session

Jay HarrisSoftware Consultant.NET Developer

Ask Questions Anytime

Please Give Feedback!http://www.speakerrate.com/jayharris/

the agenda
The Agenda

Anatomy of the ASP.NET Page Life Cycle

the agenda5

Page Start

Agenda

Start

The Agenda

Anatomy of the ASP.NET Page Life Cycle

System Assigns Properties:RequestResponseUICulture

System determines if the request is new or postback

the agenda6

Page Initialization

Agenda

Start

Initialization

The Agenda

Anatomy of the ASP.NET Page Life Cycle

System Prepares Controls:Available by UniqueIDProperties set from code/CIF values

Applies Theme & MasterPageHandled in PreInit

the agenda7

Page Load

Agenda

Start

Initialization

Load

The Agenda

Anatomy of the ASP.NET Page Life Cycle

If IsPostBack:Restores Properties from State

the agenda8

Render

Agenda

Start

Initialization

Load

Render

The Agenda

Anatomy of the ASP.NET Page Life Cycle

Saves ViewState & Renders

the agenda9

Control Validation

Agenda

Start

Initialization

Load

Validation

Render

The Agenda

Anatomy of the ASP.NET Page Life Cycle

If IsPostBack & Validators exist:Runs Validate() for All Validators…even the disabled ones

the agenda10

PostBack Events

Agenda

Start

Initialization

Load

Validation

Events

Render

The Agenda

Anatomy of the ASP.NET Page Life Cycle

If IsPostBack:Runs any Event Handlers as needed

Includes events such as:TextBox.TextChangedDropDownList.SelectedIndexChangedButton.Click

the agenda11

Easy to Remember

Agenda

Start

Initialization

Load

Validation

Events

Render

The Agenda

Anatomy of the ASP.NET Page Life Cycle

“SILVER!”(as in medals & bars)

the agenda12

Easy to Remember

Agenda

Start

Load

  • Initialization

Validation

Events

Render

The Agenda

Anatomy of the ASP.NET Page Life Cycle

Wait. “SLIVER?!?”(no, not wood)

the agenda13

Easy to Remember

Agenda

Start

  • Load

Initialization

Validation

Events

Render

The Agenda

Anatomy of the ASP.NET Page Life Cycle

Huh? “LIVER?!?”(eww. gross. and there’s no onions)

the agenda14

Easy to Remember

Agenda

Start

Initialization

Load

Validation

Events

Render

The Agenda

Anatomy of the ASP.NET Page Life Cycle

“Hi-yo, Silver, away!”(The Lone Ranger)

running the show
Running the Show

Harnessing the ASP.NET Page Life Cycle*

running the show16
Running the Show

Subjected to the terms, limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, successors, and approval of the ASP.NET worker process.

Harnessing the ASP.NET Page Life Cycle*

running the show17

Debugging Events

Features

Page-Level Tracing:

<%@ Page Trace=“true” %>

Tracing

Page-Level

Running the Show

Harnessing the ASP.NET Page Life Cycle*

running the show18

Debugging Events

Features

  • Page-Level Tracing:
    • <%@ Page Trace=“true” %>
  • *Not available after Render

Tracing*

Page-Level*

Running the Show

Subjected to the terms, limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, successors, and approval of the ASP.NET worker process.

Harnessing the ASP.NET Page Life Cycle*

running the show19

Debugging Events

Features

Application-Level Tracing:

<configuration><system.web> <trace enabled=“true” /> </system.web></configuration>

Tracing*

Page-Level*

App-Level

Running the Show

Harnessing the ASP.NET Page Life Cycle*

running the show20

Debugging Events

Features

  • Application-Level Tracing:
    • <configuration> <system.web> <trace enabled=“true” /> </system.web></configuration>
  • *Site-Wide Performance Hit

Tracing*

Page-Level*

App-Level*

Running the Show

Subjected to the terms, limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, successors, and approval of the ASP.NET worker process.

Harnessing the ASP.NET Page Life Cycle*

running the show21

Event Wiring

Features

  • Using the Constructor:
    • public MyPage(){this.Load += PageLoad;}protected void PageLoad(…)

Tracing*

Wiring

Manual

Running the Show

Harnessing the ASP.NET Page Life Cycle*

running the show22

Event Wiring

Features

  • Using the Constructor:
    • public MyPage(){this.Load += PageLoad;}protected void PageLoad(…)
  • *Wire Control events in Page Init

Tracing*

Wiring*

Manual*

Running the Show

Subjected to the terms, limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, successors, and approval of the ASP.NET worker process.

Harnessing the ASP.NET Page Life Cycle*

running the show23

Event Wiring, Auto

Features

  • Auto-Wire via Page_EventName:
    • protected void Page_Load(…){ //Do some stuff}

Tracing*

Wiring*

Manual*

Auto-Wire

Running the Show

Harnessing the ASP.NET Page Life Cycle*

running the show24

Event Wiring, Auto

Features

  • Auto-Wire via Page_EventName:
    • protected void Page_Load(…){ //Do some stuff}
  • *Page only. Not for controls.*Performance Hit.

Tracing*

Wiring*

Manual*

Auto-Wire*

Running the Show

Subjected to the terms, limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, successors, and approval of the ASP.NET worker process.

Harnessing the ASP.NET Page Life Cycle*

running the show25

Event Execution

Features

Top-Down Control Tree Execution

First load the Page…then load the Container Control…then load the Child Control

Tracing*

Wiring*

Execution

Tree

Running the Show

Harnessing the ASP.NET Page Life Cycle*

running the show26

Event Execution

Features

  • Top-Down Control Tree Execution

First load the Page…then load the Container Control…then load the Child Control

*Except: Initialization & Unload

First unload Controls, then the Page

Tracing*

Wiring*

Execution*

Tree*

Running the Show

Subjected to the terms, limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, successors, and approval of the ASP.NET worker process.

Harnessing the ASP.NET Page Life Cycle*

running the show27

Event Execution

Features

  • Index-based Collection Execution
    • page.Controls[0].OnLoadpage.Controls[1].OnLoadpage.Controls[2].OnLoad…page.Controls[n].OnLoad

Tracing*

Wiring*

Execution*

Tree*

Collection

Running the Show

Harnessing the ASP.NET Page Life Cycle*

running the show28

Event Execution

Features

  • Index-based Collection Execution
    • page.Controls[0].OnLoadpage.Controls[1].OnLoadpage.Controls[2].OnLoad…page.Controls[n].OnLoad
  • * When was it added to Controls?

Tracing*

Wiring*

Execution*

Tree*

Collection*

Running the Show

Subjected to the terms, limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, successors, and approval of the ASP.NET worker process.

Harnessing the ASP.NET Page Life Cycle*

running the show29

Event Execution

Features

  • Index-based Collection Execution
    • page.Controls[0].OnLoadpage.Controls[1].OnLoadpage.Controls[2].OnLoad…page.Controls[n].OnLoad
  • * When was it added to Controls?

Tracing*

Wiring*

Execution*

Tree*

Collection*

Running the Show

Subjected to the terms, limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, successors, and approval of the ASP.NET worker process.

Harnessing the ASP.NET Page Life Cycle*

running the show30

Loading ViewState

Features

Control State is loaded twice

Once immediately prior to LoadOnce immediately following Load

Tracing*

Wiring*

Execution*

ViewState

Running the Show

Harnessing the ASP.NET Page Life Cycle*

running the show31

Loading ViewState

Features

Control State is loaded twice

Once immediately prior to LoadOnce immediately following Load

*Not restored if modified prior

Tracing*

Wiring*

Execution*

ViewState*

Running the Show

Subjected to the terms, limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, successors, and approval of the ASP.NET worker process.

Harnessing the ASP.NET Page Life Cycle*

displaying data
Displaying Data

Effectively Binding Dynamic Data to the Page

displaying data33

DataBind();

Data

  • DataBind();
Displaying Data

Effectively Binding Dynamic Data to the Page

Control.DataBind();Only for the specific contoland its child controls

Page.DataBind();Binds all controls on the page

displaying data34

Binding Events

Data

DataBind();

EventsDataBinding

Displaying Data

Effectively Binding Dynamic Data to the Page

DataBindingBegins DataBinding of a control

displaying data35

Binding Events

Data

DataBind();

EventsDataBindingRwCreated

Displaying Data

Effectively Binding Dynamic Data to the Page

RowCreated / ItemCreatedManipulating item markupCannot be dependent on control data

Row vs. Item Usage:RowCreated: GridViewItemCreated: DataGrid,ListView, Repeater, and everything else.

displaying data36

Binding Events

Data

  • DataBind();

EventsDataBindingRwCreatedRwDBound

Displaying Data

Effectively Binding Dynamic Data to the Page

RowDataBound / ItemDataBoundManipulating item dataData is available within controls

Row vs. Item Usage:RowCreated: GridViewItemCreated: DataGrid, ListView, Repeater, and everything else.

wrap up

Resources & Questions

  • ResourcesMSDN: http://tinyurl.com/AspNetPageLifeCycleBlog: http://www.cptloadtest.comEmail: [email protected]: @jayharris

Questions?

Wrap-up

Taking the Next Steps with the ASP.NET Page Life Cycle

wrap up38

Thank You

Jay Harris OnlineBlog: http://www.cptloadtest.comEmail: [email protected]: @jayharris

FeedbackRate: http://www.speakerrate.com/jayharris

Wrap-up

Taking the Next Steps with the ASP.NET Page Life Cycle

ad