Asp net page life cycle
Download
1 / 38

ASP Page Life Cycle - PowerPoint PPT Presentation


  • 208 Views
  • Updated 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 l.jpg

ASP.NET Page Life Cycle

Dev Basics Series

Jay Harris


Overview l.jpg

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 l.jpg

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 l.jpg
The Agenda

Anatomy of the ASP.NET Page Life Cycle


The agenda5 l.jpg

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 l.jpg

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 l.jpg

Page Load

Agenda

Start

Initialization

Load

The Agenda

Anatomy of the ASP.NET Page Life Cycle

If IsPostBack:Restores Properties from State


The agenda8 l.jpg

Render

Agenda

Start

Initialization

Load

Render

The Agenda

Anatomy of the ASP.NET Page Life Cycle

Saves ViewState & Renders


The agenda9 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg
Running the Show

Harnessing the ASP.NET Page Life Cycle*


Running the show16 l.jpg
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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg
Displaying Data

Effectively Binding Dynamic Data to the Page


Displaying data33 l.jpg

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 l.jpg

Binding Events

Data

DataBind();

EventsDataBinding

Displaying Data

Effectively Binding Dynamic Data to the Page

DataBindingBegins DataBinding of a control


Displaying data35 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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