ASP.NET Validation Controls

Below are types of asp.net validation controls:
1. Required FieldValidator
    Ensures user does not left control without data.
Reference:  How to: Validate Required Entries for ASP.NET Server Controls.

2. RangeValidator
   Check if entered values are in between given upper and lower boundries.
Reference:   How to: Validate Against a Range of Values for ASP.NET Server Controls.

3. RegularExpressionValidator
   Checks that entered data matches to the given pattern of Regular Expression.
Reference:  How to: Validate Against Patterns for ASP.NET Server Controls.

4. CompareValidator
    Compares the values entered by user with other control or constant value or
Reference: How to: Validate Against a Specific Value for ASP.NET Server Controls and How to: Validate Against a Data Type for ASP.NET Server Controls.

5. Custom Validator
   Check the entered values agains the logic you write yourself for validation.
Reference: How to: Validate with a Custom Function for ASP.NET Server Controls and How to: Validate Against Values in a Database for ASP.NET Server Controls.

ASP.Net Page life Cycle Events

Below are ASP.net Page life Cycle Events:

1.PreInit
   We can use PreInit event to check IsPostBack property, if it is a new request or is it a postback. Also Master pages, Themes and profile values get set dynamically here. No control data ans control properties values from viewsate is loaded here.

2.Init
   This event get raised after all controls get initialized. Use this event to read and initialize controls properties.

3.Init Complete
  Raised by Page object and used to complete all initialization.
  
4.PreLoad
   Use this event to do some process on the controls or page before loads event occures. This load viewstate data for page and itls all contrlos

5.Load
   Page and it's all controls and controls child controlls totally get loaded during this event. Use this event to set the properties of the controls.

6.Control Events
    Use this event to handle specific controls event like button click event.

7.Load Ccomplete
   Use this event to do the tasks inorder to complete the page loading.

8. PreRender
   This event occure for every control on page and use this event to apply final changes to controls.

9.Save State complete
   This event performs the tasks that required to save view state.

10.Render
   Page object call Render method of all the controls that writes the markup for each control.

11.Unload
  This event occures for page and its all controls. Use this event to do final work on page like closinf opened files, closing database connection..etc

ASP.Net Page Life Cycle

How page life cycle works in asp.net?
  • Page request:
            This is a stage before page life cycle starts. This step happens when user sends request for page. ASP.Net decides whether to parse and compile the requested page or just catched verions of page need to be send in response.
  • Start:
           In this step page request and response properties get set. Also page determines whether it is a page post back ot it is a new request and based on that sets IsPostBack() property value and also sets UICulture.
  • Page Initialization:
         In this step all the controls on page a available and each controls unique Id's get set. Also themes get set. But data is not loaded for the controls and control property values are not restored from viewstate.
  • Page load:
        In this step if request is a postback request then dat get loaded fro controls from viewstate and control state.
  • Validation:
        In this step Validate method of all valiation controls get called and it sets IsValid property of each individual validator control and of the page.
  • Postback event handling:
          If reuest is a postback, event handlers get called.
  • Rendering:
           In this step, page calls render method for each control and writes output to page response proerty. Before Rendering viewsate get saved for page and all it's controls.
  • Unload:
           This step happens when page and it's controls are fully loaded and sent to the client and ready to be discarded. Page properties like Response and Request are unloaded at this phase.