Friday, June 8, 2012

ASP.net page life cycle.

1)PreInit: The entry point of page life cycle is the pre-initialization phase called preinit. This is only event where you can access master page and themes programatically. You can dynamically set values of master pages and themes in this event. You can also create dynamic controls in this event.
Preinit()
{
//Set master pages and themes dynamically
}

2)Init(): This event fires after each control has been initialized ,each controls unique id is set and skin settings have been applied. Yo can use this event to change initialization values for controls.
3)InitComplete: Raise omnce all initializations of page and its controls have been completed. till now viewstate values are not yet loaded hence you can use this event to change viewstate that you want make sure are persistested after the next post back.

4)PreLoad(): Raised after the page loads viewstate for itself and for all controls and after it processes post back data that is included with the request instance.
LoadsViewstate, Postbackdata.

5)Load(): In this event the page will be restored to previous state incase of postbacks. Code in this page checks fr the postback and then set control properties appropriately.This is the first place in page lifecycle where ll the controls values are restored.

6)ControlEvents : ASP.net now calls any event on the page or its cntrols that caused postback to occur.

7)LoadComplete:  This signals end of load is completed.

8)SaveViewStateComplete: Prior to this event the viewstate for the page and its controls will be set. Any changes of page controls at this point or beyond are ignored.

9)Render: This is method of page object and its controls. At this point asp.net calls methods on each page controls to get its output. the Render method generates client-side html ,Dhtml and script that are necessary to dispay a controsl at browser.

10)Unload : This is for the clean up code. After this page's html is renderes and the objects are disposed off during this event.

--If you find it is hard to remember every thing first tell all the events and next starts explain each of them. when you said all the events the interviewer will be satisfy with that if you are lucky.



No comments:

Post a Comment