01_Request_LifeCycle

01_Request_LifeCycle - Page LifeCycle in ASP.NET A Web Form...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Page LifeCycle in ASP.NET
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
A Web Form in ASP.NET <form id="form1" runat="server"> <asp:Label ID="Label1" runat="server" text="A Label!"/> <asp:Label ID="TextBox1" runat="server" text="A TextBox!"/> <asp:Button ID="Button1" runat="server" onClick="Label1.text='Hello'"/> </form>
Background image of page 2
After Server-side Processing EG, TextBox1 produces: <input type="Text" id="TextBox1" name="TextBox1" value="A TextBox!"/> Typically a page posts back to itself. Clicking the button causes a form submit event.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
A Note about View State If you click Button1, Label1 will be changed to show ("Hello"). When the page reloads Label1 will still say "Hello", even though it's default value is "A Label!". ASP.NET inserts a hidden field into the form (_VIEWSTATE) which holds the current state of all controls where they differ from the default values (defined in the ASPX file).
Background image of page 4
ASP.NET Lifecycle Phases 1. Init 2. Load 3. Events 4. Render 5. Unload
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Lifecycle - 1: Init Build up a tree of controls from the ASPX file. (All controls have their ID set at this stage) Process the View State, giving each control a chance to update its state. For example Label1.Text = "Hello". (View State data is keyed by Control ID). Anything in the View State that didn't match a known control ID is placed in an "Unmatched" list. Turn on view state tracking. Any changes to controls will now be recorded in the View State.
Background image of page 6
Lifecycle - 1: Init When the form was submitted some controls (for example TextBox1) will submit their values as a
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 21

01_Request_LifeCycle - Page LifeCycle in ASP.NET A Web Form...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online