Virtual Classes Logo          Virtual Classes
    Read Anytime,Anywhere

Web Pages

ASP.NET Web Pages is a framework to create dynamic web pages.
A simple HTML web page is static, its content is determined by the fixed HTML markup that's in the page while ASP.NET Web Pages those you create on the fly by using code are dynamic pages. Web pages provides an easy way to combine HTML, CSS, JavaScript and server code.
When a page request is sent to the Web server, the page is run through a series of events during its creation and disposal. At each stage of the page life cycle, the page raises some events. Developers need to know about these events to write his application logic.

Page life cycle events:
1-PreInit :The entry point of the page life cycle is the pre-initialization phase called “PreInit”.PreInit is the first event in page life cycle. Developer can write the code in this event to determines whether the page is a postback by checking IsPostback property. If developer wants to change themes and master pages, creates dynamic controls, and gets and sets profile property values then it is the best place for that.
2-Init :This event fires after each control has been initialized, each control's UniqueID is set and any skin settings have been applied. You can use this event to change initialization values for controls. The “Init” event is fired first for the most bottom control in the hierarchy, and then fired up the hierarchy until it is fired for the page itself.
3-InitComplete :InitComplete Raised once all initializations of the page and its controls have been completed. Till now the viewstate values are not yet loaded, hence you can use this event to make changes to view state that you want to make sure are persisted after the next postback. InitComplete event allows tracking of view state. All the controls turn on view-state tracking.
4-LoadViewState :PreLoad Raised after the page loads view state for itself and all controls, and after it processes postback data that is included with the Request instance LoadViewState event allows loading view state information into the controls.
5-PreLoad : PreLoad occurs before the post back data is loaded in the controls.

6-Load :The Load event is raised for the page first and then recursively for all child controls. The controls in the control tree are created.
7-LoadComplete :The loading process is completed, control event handlers are run, and page validation takes place.
8-PreRender : PreRender Allows final changes to the page or its control. This event takes place before saving ViewState, so any changes made here are saved. The PreRender event occurs just before the output is rendered. By handling this event, pages and controls can perform any updates before the output is rendered.
9-PreRenderComplete : As the PreRender event is recursively fired for all child controls, this event ensures the completion of the pre-rendering phase.
10-SaveStateComplete : Prior to this event the view state for the page and its controls is set. Any changes to the page’s controls at this point or beyond are ignored. State of control on the page is saved. Personalization, control state and view state information is saved. The HTML markup is generated.
11-Render : This is a method of the page object and its controls (and not an event). At this point, ASP.NET calls this method on each of the page’s controls to get its output. The Render method generates the client-side HTML, Dynamic Hypertext Markup Language (DHTML), and script that are necessary to properly display a control at the browser.
12-UnLoad :The UnLoad event is the last event in the page life cycle. Page raises the UnLoad event for all controls recursively and lastly for the page itself. UnLoad This event is used for cleanup code. Final cleanup of all resources and references, such as database connections, are freed in this event. During this event, you should destroy any objects or references you have created in building the page. At this point, all processing has occurred and it is safe to dispose of any remaining objects, including the Page object.