1 / 38

ASP.NET Page Life Cycle

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

Pat_Xavi
Download Presentation

ASP.NET Page Life Cycle

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASP.NET Page Life Cycle Dev Basics Series Jay Harris

  2. 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.

  3. 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/

  4. The Agenda Anatomy of the ASP.NET Page Life Cycle

  5. 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

  6. 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

  7. Page Load Agenda Start Initialization Load The Agenda Anatomy of the ASP.NET Page Life Cycle If IsPostBack:Restores Properties from State

  8. Render Agenda Start Initialization Load Render The Agenda Anatomy of the ASP.NET Page Life Cycle Saves ViewState & Renders

  9. 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

  10. 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

  11. 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)

  12. 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)

  13. 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)

  14. 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)

  15. Running the Show Harnessing the ASP.NET Page Life Cycle*

  16. 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*

  17. Debugging Events Features Page-Level Tracing: <%@ Page Trace=“true” %> Tracing Page-Level Running the Show Harnessing the ASP.NET Page Life Cycle*

  18. 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*

  19. 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*

  20. 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*

  21. 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*

  22. 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*

  23. 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*

  24. 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*

  25. 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*

  26. 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*

  27. 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*

  28. 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*

  29. 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*

  30. 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*

  31. 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*

  32. Displaying Data Effectively Binding Dynamic Data to the Page

  33. 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

  34. Binding Events Data DataBind(); EventsDataBinding Displaying Data Effectively Binding Dynamic Data to the Page DataBindingBegins DataBinding of a control

  35. 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.

  36. 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.

  37. Resources & Questions • ResourcesMSDN: http://tinyurl.com/AspNetPageLifeCycleBlog: http://www.cptloadtest.comEmail: jayharris@harrisdesigns.comTwitter: @jayharris Questions? Wrap-up Taking the Next Steps with the ASP.NET Page Life Cycle

  38. Thank You Jay Harris OnlineBlog: http://www.cptloadtest.comEmail: jayharris@harrisdesigns.comTwitter: @jayharris FeedbackRate: http://www.speakerrate.com/jayharris Wrap-up Taking the Next Steps with the ASP.NET Page Life Cycle

More Related