Sunday, August 25, 2013

ASP.NET Life Cycle Interview Questions and Answers

1. What’ is the sequence in which ASP.NET events are processed?

Following is the sequence in which the events occur:-
• Page_Init.
• Page Load.
• Control events
• Page- Unload event.

2. Difference Between Page Init and Page Load events?

Page_init event only occurs when first time the page is started, but Page Load occurs in subsequent request of the page.

3. In which event are the controls fully loaded?


Page load event guarantees that all controls are fully loaded.
Controls are also accessed in Page_Init events but you will see that view state is not fully loaded during this event.

4. How can we identify that the Page is Post Back?

Page object has an IsPostBack” property, which can be checked to know that is the page posted back.


5. How do we ensure view state is not tampered?


Using the @Page directive and setting EnableViewState’ property to True.

6. What is the use of Smart Navigation property?

It’s a feature provided by ASP. NET to prevent flickering and redrawing when the page is posted back.
 but this is only supported for IE browser.

7. Where is View State information stored?

In HTML Hidden Fields.

8. In which event are the controls fully loaded?

Page load event guarantees that all controls are fully loaded. 

Controls are also accessed in Page_Init events

but you will see that view state is not fully loaded during this event

9. What is the lifespan for items stored in ViewState?

Lifetime of the current page expires including the postbacks to the same page.

 10. What are the advantages of the code-behind feature?
  •     Makes code easy to understand and debug by separating application logic from HTML tags
  •     Provides the isolation of effort between graphic designers and software engineers
  •     Removes the problems of browser incompatibility by providing code files to exist on the Web server and supporting Web pages to be compiled on demand. 
 11. In which event are the controls fully loaded? 

Page load event guarantees that all controls are fully loaded

Controls are also accessed in Page_Init events but you will see that view state is not fully loaded.

12. What is the lifespan for items stored in ViewState? 

Lifetime of the current page expires including the postbacks to the same page. 

13. What is ViewState?
 

ViewState - store the value of a page and its controls just before posting the page. 

Once the page is posted, the first task by the page processing is to restore the ViewState to get the values of the controls. 

 14.Describe the complete Life Cycle of a Web page.When we execute a Web page, it passes from the following stages, which are collectively known as Web page lifecycle:
  1.Page request -
 


ASP.NET makes sure the page either parsed or compiled and a cached version of the page can be sent in response
 
   2.Start -
 


Sets the Request and Response page properties and the page check the page request is either a postback or a new request

   3. Page Initialization - 

Page initialize and the control's Unique Id property are set.
 
    4.Load -
 


If the request is postback
      control properties are loaded without loading the view state and control state 

otherwise 
     loads the view state
 
    5.Validation -
 


The controls are validated
 
    6.Postback event handling -


If the request is a postback, handles the event
 
    7.Rendering -
 


Page invokes the Render method to each control for return the output

   8. Unload -

Page is completely rendered and sent to the client, the page is unloaded. 




15.What events are fired when a page loads?
The following events fire when a page loads:

    Init() - Fires when the page is initializing.
    LoadViewState() - Fires when the view state is loading.
    LoadPostData() - Fires when the postback data is processing.
    Load() - Fires when the page is loading.
    PreRender() - Fires at the brief moment before the page is displayed to the user as HTML.
    Unload() - Fires when the page is destroying the instances of server controls.






No comments:

Post a Comment