• Save
Dev Basics: The ASP.NET Page Life Cycle
Upcoming SlideShare
Loading in...5
×
 

Dev Basics: The ASP.NET Page Life Cycle

on

  • 8,646 views

When a request occurs for an ASP.Net page, the response is processed through a series of events before being sent to the client browser. These events, known as the Page Life Cycle, are a complicated ...

When a request occurs for an ASP.Net page, the response is processed through a series of events before being sent to the client browser. These events, known as the Page Life Cycle, are a complicated headache when used improperly, manifesting as odd exceptions, incorrect data, performance issues, and general confusion. It seems simple when reading yet-another-book-on-ASP.NET, but never when applied in the real world. In this session, we decompose this mess, and turn the Life Cycle into an effective and productive tool. No ASP.NET MVC, no Dynamic Data, no MoroRail, no technologies of tomorrow, just the basics of ASP.NET, using the tools we have available in the office, today.

Statistics

Views

Total Views
8,646
Views on SlideShare
8,618
Embed Views
28

Actions

Likes
7
Downloads
0
Comments
0

4 Embeds 28

http://www.slideshare.net 18
http://speakerrate.com 6
http://www.linkedin.com 3
http://www.docseek.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Dev Basics: The ASP.NET Page Life Cycle Dev Basics: The ASP.NET Page Life Cycle Presentation Transcript

  • ASP.NET Page Life Cycle Dev Basics Series Jay Harris
  • About the Talk Covers Life Cycle Discuss: Data Binding ASP.NET Page Life Cycle Tips & Tricks Proper use of Data Binding Events Pain Points Involves only ASP.NET Events No MVC. No Silverlight. No Controls or DataSource Controls Tips & Tricks. And Traps. Overview What to expect out of this session
  • About the Speaker Covers Life Cycle Jay Harris Data Binding Software Consultant Tips & Tricks .NET Developer Pain Points Ask Questions Anytime Please Give Feedback! http://www.speakerrate.com/jayharris/ Overview What to expect out of this session
  • The Agenda Anatomy of the ASP.NET Page Life Cycle
  • Page Start Agenda Start System Assigns Properties: Request Response UICulture System determines if the request is new or postback The Agenda Anatomy of the ASP.NET Page Life Cycle
  • Page Initialization Agenda Start System Prepares Controls: Initialization Available by UniqueID Properties set from code/CIF values Applies Theme & MasterPage Handled in PreInit The Agenda Anatomy of the ASP.NET Page Life Cycle
  • Page Load Agenda Start If IsPostBack: Initialization Restores Properties from State Load The Agenda Anatomy of the ASP.NET Page Life Cycle
  • Render Agenda Start Saves ViewState & Renders Initialization Load Render The Agenda Anatomy of the ASP.NET Page Life Cycle
  • Control Validation Agenda Start If IsPostBack & Validators exist: Initialization Runs Validate() for All Validators Load …even the disabled ones Validation Render The Agenda Anatomy of the ASP.NET Page Life Cycle
  • PostBack Events Agenda Start If IsPostBack: Initialization Runs any Event Handlers as needed Load Validation Includes events such as: Events Render TextBox.TextChanged DropDownList.SelectedIndexChanged Button.Click The Agenda Anatomy of the ASP.NET Page Life Cycle
  • Easy to Remember Agenda Start Initialization Load Validation “SILVER!” Events (as in medals & bars) Render The Agenda Anatomy of the ASP.NET Page Life Cycle
  • Easy to Remember Agenda Start Load Initialization Validation Wait. “SLIVER?!?” Events (no, not wood) Render The Agenda Anatomy of the ASP.NET Page Life Cycle
  • Easy to Remember Agenda Start Load Initialization Validation Huh? “LIVER?!?” Events (eww. gross. and there’s no onions) Render The Agenda Anatomy of the ASP.NET Page Life Cycle
  • Easy to Remember Agenda Start Initialization Load Validation “Hi-yo, Silver, away!” Events (The Lone Ranger) Render The Agenda Anatomy of the ASP.NET Page Life Cycle
  • Running the Show Harnessing the ASP.NET Page Life Cycle*
  • Subjected to the terms, Running the Show limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, Harnessing the ASP.NET Page Life Cycle* successors, and approval of the ASP.NET worker process.
  • Debugging Events Features Page-Level Tracing: Tracing Page-Level <%@ Page Trace=“true” %> Running the Show Harnessing the ASP.NET Page Life Cycle*
  • Debugging Events Features Page-Level Tracing: Tracing* Page-Level* <%@ Page Trace=“true” %> *Not available after Render Subjected to the terms, Running the Show limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, Harnessing the ASP.NET Page Life Cycle* successors, and approval of the ASP.NET worker process.
  • Debugging Events Features Application-Level Tracing: Tracing* Page-Level* App-Level <configuration> <system.web> <trace enabled=“true” /> </system.web> </configuration> Running the Show Harnessing the ASP.NET Page Life Cycle*
  • Debugging Events Features Application-Level Tracing: Tracing* Page-Level* App-Level* <configuration> <system.web> <trace enabled=“true” /> </system.web> </configuration> *Site-Wide Performance Hit Subjected to the terms, Running the Show limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, Harnessing the ASP.NET Page Life Cycle* successors, and approval of the ASP.NET worker process.
  • Event Wiring Features Using the Constructor: Tracing* Wiring Manual public MyPage() { this.Load += PageLoad; } protected void PageLoad(…) Running the Show Harnessing the ASP.NET Page Life Cycle*
  • Event Wiring Features Using the Constructor: Tracing* Wiring* Manual* public MyPage() { this.Load += PageLoad; } protected void PageLoad(…) *Wire Control events in Page Init Subjected to the terms, Running the Show limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, Harnessing the ASP.NET Page Life Cycle* successors, and approval of the ASP.NET worker process.
  • Event Wiring, Auto Features Auto-Wire via Page_EventName: Tracing* Wiring* Manual* protected void Page_Load(…) Auto-Wire { //Do some stuff } Running the Show Harnessing the ASP.NET Page Life Cycle*
  • Event Wiring, Auto Features Auto-Wire via Page_EventName: Tracing* Wiring* Manual* protected void Page_Load(…) Auto-Wire* { //Do some stuff } *Page only. Not for controls. *Performance Hit. Subjected to the terms, Running the Show limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, Harnessing the ASP.NET Page Life Cycle* successors, and approval of the ASP.NET worker process.
  • Event Execution Features Top-Down Control Tree Execution Tracing* Wiring* Execution First load the Page Tree …then load the Container Control …then load the Child Control Running the Show Harnessing the ASP.NET Page Life Cycle*
  • Event Execution Features Top-Down Control Tree Execution Tracing* Wiring* Execution* First load the Page Tree* …then load the Container Control …then load the Child Control *Except: Initialization & Unload First unload Controls, then the Page Subjected to the terms, Running the Show limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, Harnessing the ASP.NET Page Life Cycle* successors, and approval of the ASP.NET worker process.
  • Event Execution Features Index-based Collection Execution Tracing* Wiring* Execution* page.Controls[0].OnLoad Tree* page.Controls[1].OnLoad Collection page.Controls[2].OnLoad … page.Controls[n].OnLoad Running the Show Harnessing the ASP.NET Page Life Cycle*
  • Event Execution Features Index-based Collection Execution Tracing* Wiring* Execution* page.Controls[0].OnLoad Tree* page.Controls[1].OnLoad Collection* page.Controls[2].OnLoad … page.Controls[n].OnLoad * When was it added to Controls? Subjected to the terms, Running the Show limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, Harnessing the ASP.NET Page Life Cycle* successors, and approval of the ASP.NET worker process.
  • Event Execution Features Index-based Collection Execution Tracing* Wiring* Execution* page.Controls[0].OnLoad Tree* page.Controls[1].OnLoad Collection* page.Controls[2].OnLoad … page.Controls[n].OnLoad * When was it added to Controls? Subjected to the terms, Running the Show limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, Harnessing the ASP.NET Page Life Cycle* successors, and approval of the ASP.NET worker process.
  • Loading ViewState Features Control State is loaded twice Tracing* Wiring* Execution* Once immediately prior to Load ViewState Once immediately following Load Running the Show Harnessing the ASP.NET Page Life Cycle*
  • Loading ViewState Features Control State is loaded twice Tracing* Wiring* Execution* Once immediately prior to Load ViewState* Once immediately following Load *Not restored if modified prior Subjected to the terms, Running the Show limitations, availability, whims, will, desires, rules, patterns, provisions, agreements, covenants, conditions, assigns, Harnessing the ASP.NET Page Life Cycle* successors, and approval of the ASP.NET worker process.
  • Displaying Data Effectively Binding Dynamic Data to the Page
  • DataBind(); Data DataBind(); Control.DataBind(); Only for the specific contol and its child controls Page.DataBind(); Binds all controls on the page Displaying Data Effectively Binding Dynamic Data to the Page
  • Binding Events Data DataBind(); DataBinding Events Begins DataBinding of a control DataBinding Displaying Data Effectively Binding Dynamic Data to the Page
  • Binding Events Data DataBind(); RowCreated / ItemCreated Events Manipulating item markup DataBinding Cannot be dependent on control data RwCreated Row vs. Item Usage: RowCreated: GridView ItemCreated: DataGrid,ListView, Repeater, and everything else. Displaying Data Effectively Binding Dynamic Data to the Page
  • Binding Events Data DataBind(); RowDataBound / ItemDataBound Events Manipulating item data DataBinding Data is available within controls RwCreated RwDBound Row vs. Item Usage: RowCreated: GridView ItemCreated: DataGrid, ListView, Repeater, and everything else. Displaying Data Effectively Binding Dynamic Data to the Page
  • Resources & Questions Resources MSDN: http://tinyurl.com/AspNetPageLifeCycle Blog: http://www.cptloadtest.com Twitter: @jayharris Questions? Wrap-up Taking the Next Steps with the ASP.NET Page Life Cycle
  • Thank You Jay Harris Online Blog: http://www.cptloadtest.com Twitter: @jayharris Feedback Rate: http://www.speakerrate.com/jayharris Wrap-up Taking the Next Steps with the ASP.NET Page Life Cycle