Download presentation
Presentation is loading. Please wait.
Published byTre Risby Modified over 9 years ago
1
ASP.NET Page Life Cycle Dev Basics Series Jay Harris
2
Overview What to expect out of this session Discuss: ASP.NET Page Life Cycle Proper use of Data Binding Events Involves only ASP.NET Events No MVC. No Silverlight. No Controls or DataSource Controls Tips & Tricks. And Traps. About the Talk Life Cycle Data Binding Tips & Tricks Pain Points Covers
3
Overview What to expect out of this session Jay Harris Software Consultant.NET Developer Ask Questions Anytime Please Give Feedback! http://www.speakerrate.com/jayharris/ About the Speaker Life Cycle Data Binding Tips & Tricks Pain Points Covers
4
The Agenda Anatomy of the ASP.NET Page Life Cycle
5
The Agenda Anatomy of the ASP.NET Page Life Cycle System Assigns Properties: Request Response UICulture System determines if the request is new or postback Page Start Start Agenda
6
The Agenda Anatomy of the ASP.NET Page Life Cycle System Prepares Controls: Available by UniqueID Properties set from code/CIF values Applies Theme & MasterPage Handled in PreInit Page Initialization Start Initialization Agenda
7
The Agenda Anatomy of the ASP.NET Page Life Cycle If IsPostBack: Restores Properties from State Page Load Start Initialization Load Agenda
8
The Agenda Anatomy of the ASP.NET Page Life Cycle Saves ViewState & Renders Render Start Initialization Load Render Agenda
9
The Agenda Anatomy of the ASP.NET Page Life Cycle If IsPostBack & Validators exist: Runs Validate() for All Validators …even the disabled ones Control Validation Start Initialization Load Validation Render Agenda
10
The Agenda Anatomy of the ASP.NET Page Life Cycle If IsPostBack: Runs any Event Handlers as needed Includes events such as: TextBox.TextChanged DropDownList.SelectedIndexChanged Button.Click PostBack Events Start Initialization Load Validation Events Render Agenda
11
The Agenda Anatomy of the ASP.NET Page Life Cycle “SILVER!” (as in medals & bars) Easy to Remember Start Initialization Load Validation Events Render Agenda
12
The Agenda Anatomy of the ASP.NET Page Life Cycle Wait. “SLIVER?!?” (no, not wood) Easy to Remember Start Load Initialization Validation Events Render Agenda
13
The Agenda Anatomy of the ASP.NET Page Life Cycle Huh? “LIVER?!?” (eww. gross. and there’s no onions) Easy to Remember Start Load Initialization Validation Events Render Agenda
14
The Agenda Anatomy of the ASP.NET Page Life Cycle “Hi-yo, Silver, away!” (The Lone Ranger) Easy to Remember Start Initialization Load Validation Events Render Agenda
15
Running the Show Harnessing the ASP.NET Page Life Cycle*
16
Running the Show Harnessing the ASP.NET Page Life Cycle* 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.
17
Debugging Events Tracing Page-Level Features Page-Level Tracing: Running the Show Harnessing the ASP.NET Page Life Cycle*
18
Debugging Events Tracing* Page-Level* Features Page-Level Tracing: *Not available after Render 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. Running the Show Harnessing the ASP.NET Page Life Cycle*
19
Debugging Events Tracing* Page-Level* App-Level Features Application-Level Tracing: Running the Show Harnessing the ASP.NET Page Life Cycle*
20
Debugging Events Tracing* Page-Level* App-Level* Features Application-Level Tracing: *Site-Wide Performance Hit Running the Show Harnessing the ASP.NET Page Life Cycle* 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.
21
Event Wiring Tracing* Wiring Manual Features Using the Constructor: public MyPage() { this.Load += PageLoad; } protected void PageLoad(…) Running the Show Harnessing the ASP.NET Page Life Cycle*
22
Event Wiring Tracing* Wiring* Manual* Features Using the Constructor: public MyPage() { this.Load += PageLoad; } protected void PageLoad(…) *Wire Control events in Page Init 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. Running the Show Harnessing the ASP.NET Page Life Cycle*
23
Event Wiring, Auto Tracing* Wiring* Manual* Auto-Wire Features Auto-Wire via Page_EventName: protected void Page_Load(…) { //Do some stuff } Running the Show Harnessing the ASP.NET Page Life Cycle*
24
Event Wiring, Auto Tracing* Wiring* Manual* Auto-Wire* Features Auto-Wire via Page_EventName: protected void Page_Load(…) { //Do some stuff } *Page only. Not for controls. *Performance Hit. 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. Running the Show Harnessing the ASP.NET Page Life Cycle*
25
Event Execution Tracing* Wiring* Execution Tree Features Top-Down Control Tree Execution First load the Page …then load the Container Control …then load the Child Control Running the Show Harnessing the ASP.NET Page Life Cycle*
26
Event Execution Tracing* Wiring* Execution* Tree* Features 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. 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 Running the Show Harnessing the ASP.NET Page Life Cycle*
27
Event Execution Tracing* Wiring* Execution* Tree* Collection Features Index-based Collection Execution page.Controls[0].OnLoad page.Controls[1].OnLoad page.Controls[2].OnLoad … page.Controls[n].OnLoad Running the Show Harnessing the ASP.NET Page Life Cycle*
28
Event Execution Tracing* Wiring* Execution* Tree* Collection* Features 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. Running the Show Harnessing the ASP.NET Page Life Cycle* Index-based Collection Execution page.Controls[0].OnLoad page.Controls[1].OnLoad page.Controls[2].OnLoad … page.Controls[n].OnLoad * When was it added to Controls?
29
Event Execution Tracing* Wiring* Execution* Tree* Collection* Features 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. Running the Show Harnessing the ASP.NET Page Life Cycle* Index-based Collection Execution page.Controls[0].OnLoad page.Controls[1].OnLoad page.Controls[2].OnLoad … page.Controls[n].OnLoad * When was it added to Controls?
30
Loading ViewState Tracing* Wiring* Execution* ViewState Features Control State is loaded twice Once immediately prior to Load Once immediately following Load Running the Show Harnessing the ASP.NET Page Life Cycle*
31
Loading ViewState Tracing* Wiring* Execution* ViewState* Features 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. Control State is loaded twice Once immediately prior to Load Once immediately following Load *Not restored if modified prior Running the Show Harnessing the ASP.NET Page Life Cycle*
32
Displaying Data Effectively Binding Dynamic Data to the Page
33
Displaying Data Effectively Binding Dynamic Data to the Page Control.DataBind(); Only for the specific contol and its child controls Page.DataBind(); Binds all controls on the page DataBind();Data DataBind();
34
Displaying Data Effectively Binding Dynamic Data to the Page DataBinding Begins DataBinding of a control Binding Events DataBind(); Events DataBinding Data
35
Displaying Data Effectively Binding Dynamic Data to the Page RowCreated / ItemCreated Manipulating item markup Cannot be dependent on control data Row vs. Item Usage: RowCreated: GridView ItemCreated: DataGrid,ListView, Repeater, and everything else. Binding Events DataBind(); Events DataBinding RwCreated Data
36
Displaying Data Effectively Binding Dynamic Data to the Page RowDataBound / ItemDataBound Manipulating item data Data is available within controls Row vs. Item Usage: RowCreated: GridView ItemCreated: DataGrid, ListView, Repeater, and everything else. Binding Events DataBind(); Events DataBinding RwCreated RwDBound Data
37
Resources & Questions Wrap-up Taking the Next Steps with the ASP.NET Page Life Cycle Resources MSDN:http://tinyurl.com/AspNetPageLifeCycle Blog:http://www.cptloadtest.com Email:jayharris@harrisdesigns.com Twitter:@jayharris Questions?
38
Thank You Wrap-up Taking the Next Steps with the ASP.NET Page Life Cycle Jay Harris Online Blog:http://www.cptloadtest.com Email:jayharris@harrisdesigns.com Twitter:@jayharris Feedback Rate:http://www.speakerrate.com/jayharris
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.