














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An in-depth look into the process of compiling an asp.net page, including the role of processing directives and the page life cycle. Learn about the different events in the page life cycle, such as preinit, init, initcomplete, load, loadcomplete, prerender, prerendercomplete, savestatecomplete, and unload.
Typology: Slides
1 / 22
This page cannot be seen from the preview
Don't miss anything!















An ASP.NET page is compiled when it is rendered for the first time A page is compiled to a class that derives from Page Parse the .aspx file and create a class that derives from Page The preceding class is then compiled to an assembly This process is transparent
.asax – application files .ascx – ASP user controls .asmx – Web services .aspx – ASP.NET Web pages
Processing directives are used to configure the runtime environment Directives can appear anywhere on a page but best practices dictate that they appear at the beginning of the page Directives begin with <%@ and end with %> Make sure you don’t forget the %>
It can appear only in .aspx pages Attributes are divided into roughly three categories Compilation Page behavior Page output
There are other tools to configure the same options beyond processing directives
See Table 3-5 on page 104 for a complete list
CodeFile lists the file containing the VB or C# code for the .aspx page Language describes the programming language for the CodeFile ClassName explicitly sets the name of the class created upon compilation
The Page class provides the basic behavior for an ASP Web page It’s objects allow you to reference The application itself ( Application ) The server itself ( Server ) The HTTP request ( HttpRequest ) The HTTP response ( HttpResponse ) The user’s session ( Session )
Controls returns a collection of controls on the page IsPostBack indicates whether the page is being loaded in response to a postback or is being loaded for the first time PreviousPage returns a reference to the caller page Only meaningful in case of a cross-page postback Check IsCrossPagePostback
DataBind binds all data bound controls to their data sources (more later) Validate causes validation controls to validate their data SetFocus sets input focus to the desired control instance There are methods to work with client script
First, this topic is very important to getting your ASP applications to work ASP uses the eventing model to Persist state from one postback to the next Create static and dynamic controls Bind control instances to data sources And much more As your book says “state is an illusion of continuity”
PreInit Event It’s the first event in the page life cycle Master page has not been associated Themes have not been associated It’s possible to change master page or theme association at this time IsCallback , IsCrossPagePostback and IsPostBack are set at this time Control instances have been created
Init Event Master page and theme have been set and cannot be changed Child controls are initialized and the ID is set Child controls are initialized recursively Init event fires for all child controls before the event fires for the page itself
Load event The event is raised first for the page and then recursively for all child controls You can access control properties and view state at this time Create dynamic controls in this event Use IsPostBack to check whether the page is being loaded in response to a postback or new page
LoadComplete fires after Load At this point, the page begins its rendering phase