Friday, November 23, 2012

ASP.NET PAGE LIFE CYCLE


ASP.NET Page Life Cycle

        

A Page in an ASP.NET application consists of server controls. There  are the fundamentals building blocks of an ASP.NET application. The life cycle of an ASP.NET page, depends on whether the page is requested for the first time or it is postback. Postback is a process by which a page can request for itself.

When The Page Is Requested For The First Time 

The life cycle of a page when requested for the first time:
  • Initializing : 
                                   During this phase, the server creates an instance of the server control.
  • Loading : 
             During this phase, the instance of the control is loaded onto the page object in which it is   defined.

  • PreRendering : 
                           During this phase, the control is loaded with the changes made to it. This prepares the controls for rendering.

  • Saving : 

                          During this phase, the  state information of the control is saved. For example, if a value is set for the control during  the Load event, it is embedded in the HTML tag that will be returned to the browser.

  • Rendering : 

                           During this phase, the server creates the corresponding HTML tag for the control.

  • Disposing :

                           During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.

  • Unloading : 

                              During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is final event in the life cycle of server controls.

Life Cycle When The Page Processed During A Postback Event

The processing sequence in which a page is processed during a postback event is:

  • Initializing : 

                                   During this phase, the server creates an instance of the server control.

    • Loading View State: 

                                     During this phase, the view state of the control posted by the client is reloaded into the new instance of the control.

    • Loading : 

                             During this phase, the instance of the control is loaded onto the page object in which it is defined.

    • Loading The Postback Data: 

                                                        During this phase, the server searches any data corresponding to the control that is loaded in the posted by the client.

    • PreRendering: 

                                           During this phase, the control is updated with the changes made to it. This prepares the controls for rendring.
    •  Saving State :
                                        During this phase, the change in the state of control between the current request and the previous request of the page is saved. For each change, the corresponding event is raised. For example, if the text of a texbox is changed, the new text is saved and a text_change event is raised.
    • Rendering : 
                               During this phase, the server creates the corresponding HTML tag for the control.
    • Disposing :
                               During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.
    • Unloading : 
                                During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is final event in the life cycle of server controls.

    The Events Associated With The Relevant Page Cycle Phases Are :

                           Page Initialization  :  Page_Init
                           View State Loading  :  LoadViewState.
                           Postback data processing  :  LoadPostData
                           Page Loading  :  Page_Load
                           PostBack Change Notification  :  Raise PostDataChangedEvent
                           PostBack Event Handing  :  RaisePostBackEvent
                           Page Pre Rendring Phase  :  Page_PreRender
                           View State Saving  :  SaveViewState
                           Page Rendring :  Page_Render
                                  Page Unloading  :  Page_UnLoad



    Key Features of C-Sharp(C#)


    Key Features of C-Sharp(C#)

    • Simple :
                    It simplifies C++ by eliminating irk some operator such as ->, : : and pointers. 
    • Consistent : 
                       It support an unified type system which eliminates the problem of varying ranges of integer types. All types are treated as object and developers can extend the type system simply and easily.
    • Modern :
                          It supports, Automatic garbage collection, modern approach to debugging, rich intrinsic model for error handling, decimal data type for financial application and robust security model.
    • Object-Oriented:
                             It support all the three tenets of object-oriented system, namely Encapsulation, Inheritance and Polymorphism.
    • Type-Safe :
                            Type safety promotes robust programs, C# incorporates a number of type-safe measures :-
                                    All dynamically allocated object and arrays are initialized to zero.
                                    Use of any uninitialized variables produces an error message by the compilers
                                    Access to array are range checked and warned if it  goes out-of-bounds.
                                    C# does not permit unsafe casts.
                                    C# enforces overflow checking in arithmetic’s operation.
                                    Reference parameters that are passed are type-safe.
                                    C# supports automatic garbage collection.
    • Versionable:
                                   Making new versions of software modules work with the existing  applications is known as versioning with the help of new and override keywords, With this support, a programmer can guarantee that his new class library will maintain binary compatibility with the existing client application.
    • Compatible :
                               C# enforces the .NET common language specification and therefore allows interoperation with other .NET language.
    • Flexible :
                         Although C# does not support pointers we may declare certain classes and methods as ‘unsafe’ and then use pointers to manipulates them. These codes are not be type-safe.
    • Inter-Operability :
                                   C# provides support for using COM objects, no matter what language was used to author them. C# also supports a special features that enables a program to call out any native API.