ASP.NET INTERVIEW QUESTIONS
ASP.NET INTERVIEW QUESTIONS:-
What is ASP.Net? What are the advantages ASP.Net Technologies?
ASP.Net is a server side Technology to develop a web based applications.ASP.Net will make use of .Net framework features.
Advantages of ASP.Net
ASP.Net is a server side Technology to develop a web based applications.ASP.Net will make use of .Net framework features.
Advantages of ASP.Net
- ASP.NET makes development simpler and easier to maintain with an event-driven, server-side programming model
- ASP.NET offers built-in security features through windows authentication or other authentication methods.
- Content and program logic are separated which reduces the inconveniences of program maintenance.
- Built-in caching features.
What are different stages of ASP.Net Page Life cycle?
Each ASP.Net Web page performs following stages/events
Each ASP.Net Web page performs following stages/events
- Page Initialization (Page_Init event)
- Page Loading (Page_Load event)
- Page Prerender (Page_Prerender)
- Page Render (Page_Render)
- Page Unload (Page_Unload)
Visit following link for more information at ASP.Net Page Life Cycle
How do you validate Input data on web page?
Before submitting a web page to server, Input validation on web page is one of the important task.ASP.Net provides below validation controls to validate data in web controls and shows user friendly Messages to the user.
ASP.Net validation Controls
Before submitting a web page to server, Input validation on web page is one of the important task.ASP.Net provides below validation controls to validate data in web controls and shows user friendly Messages to the user.
ASP.Net validation Controls
- Required field validator control
- Compare validator control
- Range Validator Control
what are the different state management techniques in ASP.Net?
Asp.Net state management can be maintained in two ways as below
Client- Side State Management
ASP.Net provides following techniques to store state information. This will improve application performance by minimizing server resource utilization
1.View state
2. Hidden Fields
3. Cookies
4. Query Strings
Server – Side State Management
With respect to Server Side State Management ASP.Net uses “Application state” and “Session state” objects to store data or user state.
Asp.Net state management can be maintained in two ways as below
Client- Side State Management
ASP.Net provides following techniques to store state information. This will improve application performance by minimizing server resource utilization
1.View state
2. Hidden Fields
3. Cookies
4. Query Strings
Server – Side State Management
With respect to Server Side State Management ASP.Net uses “Application state” and “Session state” objects to store data or user state.
What are the differences between custom Web control and user control?
Custom Web control is a control that inherits from web server control available in ASP.Net.
A Custom Web Control could be compiled into separate .dll file. This custom Web control can be shared across all application by installing this dll in to Global Assembly Catch.
Custom Web control is a control that inherits from web server control available in ASP.Net.
A Custom Web Control could be compiled into separate .dll file. This custom Web control can be shared across all application by installing this dll in to Global Assembly Catch.
User Control is a file (.ascx file) that contains a set of ASP.Net controls and code grouped together to provide common functionality across the application. User control can be used on different web pages of the application.
Explain ASP.Net Catching? What are different catching mechanisms available in ASP.Net?
ASP.Net catching one of the important performance factor for large web applications.
ASP.Net Catching stores frequently accessed data in to catch object.
There are two different types catching in ASP.Net
1.Application Catching
2.Page Output Catching
ASP.Net catching one of the important performance factor for large web applications.
ASP.Net Catching stores frequently accessed data in to catch object.
There are two different types catching in ASP.Net
1.Application Catching
2.Page Output Catching
ASP.NET Page Life Cycle Overview
.NET Framework 4

183 out of 256 rated this helpful - Rate this topic
Updated: May 2011
When an ASP.NET page runs, the page goes through a life cycle in which it performs a series of processing steps. These include initialization, instantiating controls, restoring and maintaining state, running event handler code, and rendering. It is important for you to understand the page life cycle so that you can write code at the appropriate life-cycle stage for the effect you intend.
If you develop custom controls, you must be familiar with the page life cycle in order to correctly initialize controls, populate control properties with view-state data, and run control behavior code. The life cycle of a control is based on the page life cycle, and the page raises many of the events that you need to handle in a custom control.
This topic contains the following sections:
- General Page Life-cycle Stages
- Life-cycle Events
- Additional Page Life Cycle Considerations
- Catch-Up Events for Added Controls
- Data Binding Events for Data-Bound Controls
- Login Control Events
In general terms, the page goes through the stages outlined in the following table. In addition to the page life-cycle stages, there are application stages that occur before and after a request but are not specific to a page. For more information, see Introduction to the ASP.NET Application Life Cycle and ASP.NET Application Life Cycle Overview for IIS 7.0.
Some parts of the life cycle occur only when a page is processed as a postback. For postbacks, the page life cycle is the same during a partial-page postback (as when you use an UpdatePanel control) as it is during a full-page postback.
Stage | Description |
Page request | The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page. |
Start | In the start stage, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. The page also sets the UICulture property. |
Initialization | During page initialization, controls on the page are available and each control's UniqueID property is set. A master page and themes are also applied to the page if applicable. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state. |
Load | During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state. |
Postback event handling | If the request is a postback, control event handlers are called. After that, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page. (There is an exception to this sequence: the handler for the event that caused validation is called after validation.) |
Rendering | Before rendering, view state is saved for the page and all controls. During the rendering stage, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream object of the page's Response property. |
Unload |
Within each stage of the life cycle of a page, the page raises events that you can handle to run your own code. For control events, you bind the event handler to the event, either declaratively using attributes such as onclick, or in code.
Pages also support automatic event wire-up, meaning that ASP.NET looks for methods with particular names and automatically runs those methods when certain events are raised. If the AutoEventWireup attribute of the @ Page directive is set to true, page events are automatically bound to methods that use the naming convention of Page_event, such as Page_Load and Page_Init. For more information on automatic event wire-up, see ASP.NET Web Server Control Event Model.
The following table lists the page life-cycle events that you will use most frequently. There are more events than those listed; however, they are not used for most page-processing scenarios. Instead, they are primarily used by server controls on the ASP.NET Web page to initialize and render themselves. If you want to write custom ASP.NET server controls, you need to understand more about these events. For information about creating custom controls, see Developing Custom ASP.NET Server Controls.
Page Event | Typical Use |
Raised after the start stage is complete and before the initialization stage begins. Use this event for the following:
![]() If the request is a postback, the values of the controls have not yet been restored from view state. If you set a control property at this stage, its value might be overwritten in the next event. | |
Raised after all controls have been initialized and any skin settings have been applied. The Init event of individual controls occurs before the Init event of the page. Use this event to read or initialize control properties. | |
Raised at the end of the page's initialization stage. Only one operation takes place between the Init and InitComplete events: tracking of view state changes is turned on. View state tracking enables controls to persist any values that are programmatically added to the ViewState collection. Until view state tracking is turned on, any values added to view state are lost across postbacks. Controls typically turn on view state tracking immediately after they raise their Init event. Use this event to make changes to view state that you want to make sure are persisted after the next postback. | |
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. | |
The Page object calls the OnLoad method on the Page object, and then recursively does the same for each child control until the page and all controls are loaded. The Load event of individual controls occurs after the Load event of the page. Use the OnLoad event method to set properties in controls and to establish database connections. | |
Control events | Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event. ![]() |
Raised at the end of the event-handling stage. Use this event for tasks that require that all other controls on the page be loaded. | |
Raised after the Page object has created all controls that are required in order to render the page, including child controls of composite controls. (To do this, the Page object calls EnsureChildControls for each control and for the page.) The Page object raises the PreRender event on the Page object, and then recursively does the same for each child control. The PreRender event of individual controls occurs after the PreRender event of the page. Use the event to make final changes to the contents of the page or its controls before the rendering stage begins. | |
Raised after each data bound control whose DataSourceID property is set calls its DataBind method. For more information, see Data Binding Events for Data-Bound Controls later in this topic. | |
Raised after view state and control state have been saved for the page and for all controls. Any changes to the page or controls at this point affect rendering, but the changes will not be retrieved on the next postback. | |
This is not an event; instead, at this stage of processing, the Page object calls this method on each control. All ASP.NET Web server controls have a Render method that writes out the control's markup to send to the browser. If you create a custom control, you typically override this method to output the control's markup. However, if your custom control incorporates only standard ASP.NET Web server controls and no custom markup, you do not need to override the Render method. For more information, see Developing Custom ASP.NET Server Controls. A user control (an .ascx file) automatically incorporates rendering, so you do not need to explicitly render the control in code. | |
Raised for each control and then for the page. In controls, use this event to do final cleanup for specific controls, such as closing control-specific database connections. For the page itself, use this event to do final cleanup work, such as closing open files and database connections, or finishing up logging or other request-specific tasks. ![]() During the unload stage, the page and its controls have been rendered, so you cannot make further changes to the response stream. If you attempt to call a method such as the Response.Write method, the page will throw an exception. |
Individual ASP.NET server controls have their own life cycle that is similar to the page life cycle. For example, a control's Init and Load events occur during the corresponding page events.
Although both Init and Load recursively occur on each control, they happen in reverse order. The Init event (and also the Unload event) for each child control occur before the corresponding event is raised for its container (bottom-up). However the Load event for a container occurs before the Load events for its child controls (top-down). Master pages behave like child controls on a page: the master page Init event occurs before the page Init and Load events, and the master page Load event occurs after the page Init and Load events.
When you create a class that inherits from the Page class, in addition to handling events raised by the page, you can override methods from the page's base class. For example, you can override the page's InitializeCulture method to dynamically set culture information. Note that when an event handler is created using the Page_event syntax, the base implementation is implicitly called and therefore you do not need to call it in your method. For example, the base page class's OnLoad method is always called, whether you create a Page_Load method or not. However, if you override the page OnLoad method with the override keyword (Overrides in Visual Basic), you must explicitly call the base method. For example, if you override the OnLoad method on the page, you must call base.Load (MyBase.Load in Visual Basic) in order for the base implementation to be run.
The following illustration shows some of the most important methods of the Page class that you can override in order to add code that executes at specific points in the page life cycle. (For a complete list of page methods and events, see the Page class.) The illustration also shows how these methods relate to page events and to control events. The sequence of methods and events in the illustration is from top to bottom, and within each row from left to right.

If controls are created dynamically at run time or declaratively within templates of data-bound controls, their events are initially not synchronized with those of other controls on the page. For example, for a control that is added at run time, the Init and Load events might occur much later in the page life cycle than the same events for controls created declaratively. Therefore, from the time that they are instantiated, dynamically added controls and controls in templates raise their events one after the other until they have caught up to the event during which it was added to the Controls collection.
To help you understand the relationship between the page life cycle and data binding events, the following table lists data-related events in data-bound controls such as the GridView, DetailsView, and FormView controls.
Control Event | Typical Use |
Raised after the control's PreRender event, which occurs after the page's PreRender event. (This applies to controls whose DataSourceID property is set declaratively. Otherwise the event happens when you call the control's DataBind method.) This event marks the beginning of the process that binds the control to the data. Use this event to manually open database connections, if required, and to set parameter values dynamically before a query is run. | |
RowCreated (GridView only) or ItemCreated (DataList, DetailsView, SiteMapPath, DataGrid, FormView, Repeater, and ListView controls) | Raised after the control's DataBinding event. Use this event to manipulate content that is not dependent on data binding. For example, at run time, you might programmatically add formatting to a header or footer row in a GridView control. |
RowDataBound (GridView only) or ItemDataBound (DataList, SiteMapPath, DataGrid, Repeater, and ListView controls) | Raised after the control's RowCreated or ItemCreated event. When this event occurs, data is available in the row or item, so you can format data or set the FilterExpression property on child data source controls in order to display related data within the row or item. |
Raised at the end of data-binding operations in a data-bound control. In a GridView control, data binding is complete for all rows and any child controls. Use this event to format data-bound content or to initiate data binding in other controls that depend on values from the current control's content. (For more information, see Catch-Up Events for Added Controls earlier in this topic.) |
Nested Data-Bound Controls
If a child control has been data bound, but its container control has not yet been data bound, the data in the child control and the data in its container control can be out of sync. This is true particularly if the data in the child control performs processing based on a data-bound value in the container control.
For example, suppose you have a GridView control that displays a company record in each row, and it displays a list of the company officers in a ListBox control. To fill the list of officers, you would bind the ListBox control to a data source control (such as SqlDataSource) that retrieves the company officer data using the company ID in a query.
If the ListBox control's data-binding properties, such as DataSourceID and DataMember, are set declaratively, the ListBox control will try to bind to its data source during the containing row's DataBinding event. However, the CompanyID field of the row does not contain a value until the GridView control's RowDataBound event occurs. In this case, the child control (the ListBox control) is bound before the containing control (the GridView control) is bound, so their data-binding stages are out of sync.
To avoid this condition, put the data source control for the ListBox control in the same template item as the ListBox control itself, and do not set the data binding properties of the ListBox declaratively. Instead, set them programmatically at run time during the RowDataBound event, so that the ListBox control does not bind to its data until the CompanyID information is available.
For more information, see Binding to Data Using a Data Source Control.
The Login control can use settings in the Web.config file to manage membership authentication automatically. However, if your application requires you to customize how the control works, or if you want to understand how Login control events relate to the page life cycle, you can use the events listed in the following table.
Control Event | Typical Use |
Raised during a postback, after the page's LoadComplete event has occurred. This event marks the beginning of the login process. Use this event for tasks that must occur prior to beginning the authentication process. | |
Raised after the LoggingIn event. Use this event to override or enhance the default authentication behavior of a Login control. | |
Raised after the user name and password have been authenticated. Use this event to redirect to another page or to dynamically set the text in the control. This event does not occur if there is an error or if authentication fails. | |
Raised if authentication was not successful. Use this event to set text in the control that explains the problem or to direct the user to a different page. |
Reference
Concepts
Other Resources
Date | History | Reason |
May 2011 | Added note about event order in master pages. | Content bug fix. |
Community Content Add
http://hemantg.blogspot.com/2010/12/aspnet-event-sequence.html

- 1/3/2011
- HemantG11
- 8/20/2012
- maxppp
This article suggest that
"Use init event to initialize control properties" and "Use the OnLoad event to set properties in controls" in Life-Cycle Events section.
Can anyone explain, What is the difference between "initialize control properties" and "set properties in controls".
"Use init event to initialize control properties" and "Use the OnLoad event to set properties in controls" in Life-Cycle Events section.
Can anyone explain, What is the difference between "initialize control properties" and "set properties in controls".

- 5/3/2012
- Sanjeev K Sharma
In this article it's mentioned in the "General Page Life Cycle Stages" that:
[[Postback event handling
If the request is a postback, control event handlers are called. After that, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.]]
Which gives the idea that the Validation is done after Control event handling. But if you continue reading, it will also say in the "Life Cycle Events" that:
[[Control events
Which gives the idea that the Validation is done after Control event handling. But if you continue reading, it will also say in the "Life Cycle Events" that:
[[Control events
Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.
Note
In a postback request, if the page contains validator controls, check the IsValid property of the Page and of individual validation controls before performing any processing.]]
Which proposes that the Validation is done before the Event handling!!!!!!!!
When on earth does the Validation occur!?
Which proposes that the Validation is done before the Event handling!!!!!!!!
When on earth does the Validation occur!?

- 4/15/2012
- Hassoon3
- 4/15/2012
- Hassoon3
How can you get the Response.StatusCode during Page_Unload?
Alternative, when is the last moment the Response object is valid?
Alternative, when is the last moment the Response object is valid?

- 3/13/2012
- IMarvinTPA
It's amazing how this short article pinpoints exactly everything you need to know to program interactive webpages.
It should have 6 out of 5 stars.
The only minor thing I found out, and that is not completely covered here is that master pages are lower in hierarchy than pages, so their init and load behave like a child control on the page.
So master page init is before page init, but what was more important to me: master page load is after page load.
[Tom Dykstra - MSFT] Thank you for the additional information -- this will be added in the next release of the documentation.
It should have 6 out of 5 stars.
The only minor thing I found out, and that is not completely covered here is that master pages are lower in hierarchy than pages, so their init and load behave like a child control on the page.
So master page init is before page init, but what was more important to me: master page load is after page load.
[Tom Dykstra - MSFT] Thank you for the additional information -- this will be added in the next release of the documentation.

- 12/21/2010
- Pieter21
- 11/13/2011
- Thomas Lee
This is the most helpful and well written help article i've seen on MSDN.
Thank whoever took the effort to write it.
Thank whoever took the effort to write it.

- 8/30/2010
- alex440
- 11/13/2011
- Thomas Lee
Hi, this http://blog.idm.fr/2010/03/aspnet-thread-agility-or-why-threadstatic-should-not-be-used.html was just brought to my attention by one of my team members and kind of surprised me. can you provide more info on this, when will the context switch occur and is it possible for different life cycles event run on different threads. if so how can you rely on the UICulture data being true. $0$0 $0 $0thank you$0

- 7/4/2011
- Natan Drozd
Contrary to what has been stated in this article, it appears that validation occurs BEFORE postback event handling.
Here is a simple test that confirms this.
Create a Web Form containing a TextBox control, a RequiredFieldValidator control and a Button control.
Set the ControlToValidate property of the validator to the ID of the TextBox.
Set the EnableClientScript property of the validator to false.
Add an event handler for the Button control.
Set a breakpoint in the Button event handler and check the value of the IsValid property of the page.
If the text box is left empty and the button is clicked, the IsValid property is false when the button event handler is called.
If a value is entered in the text box before clicking on the button, the IsValid property is true when the button event handler is called.
The IsValid property is being set BEFORE the event handler for the button is called.
This behavior seems logical and is consistent with the documentation in the "When Validation Occurs" section at the following link.
http://msdn.microsoft.com/en-us/library/7kh55542.aspx
Here it is stated that "Validation occurs after page initialization (that is, after view state and postback data have been processed) but before any change or click event handlers are called."
[Tom Dykstra - MSFT] What you see in the Button event handler is because the Button is the control that caused the validation. If you extend your example by adding a TextChanged event handler for the text box and placing a breakpoint in it, then try to access IsValid from that handler you will get the following error message: "Page.IsValid cannot be called before validation has taken place. It should be queried in the event handler for a control that has CausesValidation=True and initiated the postback, or after a call to Page.Validate." This exception will be called out in a future release of the documentation.
Here is a simple test that confirms this.
Create a Web Form containing a TextBox control, a RequiredFieldValidator control and a Button control.
Set the ControlToValidate property of the validator to the ID of the TextBox.
Set the EnableClientScript property of the validator to false.
Add an event handler for the Button control.
Set a breakpoint in the Button event handler and check the value of the IsValid property of the page.
If the text box is left empty and the button is clicked, the IsValid property is false when the button event handler is called.
If a value is entered in the text box before clicking on the button, the IsValid property is true when the button event handler is called.
The IsValid property is being set BEFORE the event handler for the button is called.
This behavior seems logical and is consistent with the documentation in the "When Validation Occurs" section at the following link.
http://msdn.microsoft.com/en-us/library/7kh55542.aspx
Here it is stated that "Validation occurs after page initialization (that is, after view state and postback data have been processed) but before any change or click event handlers are called."
[Tom Dykstra - MSFT] What you see in the Button event handler is because the Button is the control that caused the validation. If you extend your example by adding a TextChanged event handler for the text box and placing a breakpoint in it, then try to access IsValid from that handler you will get the following error message: "Page.IsValid cannot be called before validation has taken place. It should be queried in the event handler for a control that has CausesValidation=True and initiated the postback, or after a call to Page.Validate." This exception will be called out in a future release of the documentation.

- 5/21/2011
- TimW01
- 6/2/2011
- Tom Dykstra - MSFT
In this article the following is said :
"Postback event handling
If the request is a postback, control event handlers are called. After that, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page."
It is my understanding that the Validate method of the validtor controls is called after Load but before the control event handlers.
The text quoted says its after the control event handlers.
Can someone clarify please?
I also think the picture my be wrong in this regard
Thank You, Tom
[Tom Dykstra - MSFT] I did some testing to check this out and I saw the sequence specified in this document: control event handlers get called first, and validation controls are validated after that. Have you tested and gotten different results?

- 9/2/2010
- TomPester
- 4/28/2011
- Tom Dykstra - MSFT
Application: BeginRequest
Application: PreAuthenticateRequest
Application: AuthenticateRequest
Application: PostAuthenticateRequest
Application: PreAuthorizeRequest
Application: AuthorizeRequest
Application: PostAuthorizeRequest
Application: PreResolveRequestCache
Application: ResolveRequestCache
Application: PostResolveRequestCache
Application: PreMapRequestHandler
Page: Construct
Application: PostMapRequestHandler
Application: PreAcquireRequestState
Application: AcquireRequestState
Application: PostAcquireRequestState
Application: PreRequestHandlerExecute
Page: AddParsedSubObject
Page: CreateControlCollection
Page: AddedControl
Page: AddParsedSubObject
Page: AddedControl
Page: ResolveAdapter
Page: DeterminePostBackMode
Page: PreInit
Control: ResolveAdapter
Control: Init
Control: TrackViewState
Page: Init
Page: TrackViewState
Page: InitComplete
Page: LoadPageStateFromPersistenceMedium
Control: LoadViewState
Page: EnsureChildControls
Page: CreateChildControls
Page: PreLoad
Page: Load
Control: DataBind
Control: Load
Page: EnsureChildControls
Page: LoadComplete
Page: EnsureChildControls
Page: PreRender
Control: EnsureChildControls
Control: PreRender
Page: PreRenderComplete
Page: SaveViewState
Control: SaveViewState
Page: SaveViewState
Control: SaveViewState
Page: SavePageStateToPersistenceMedium
Page: SaveStateComplete
Page: CreateHtmlTextWriter
Page: RenderControl
Page: Render
Page: RenderChildren
Control: RenderControl
Page: VerifyRenderingInServerForm
Page: CreateHtmlTextWriter
Control: Unload
Control: Dispose
Page: Unload
Page: Dispose
Application: PostRequestHandlerExecute
Application: PreReleaseRequestState
Application: ReleaseRequestState
Application: PostReleaseRequestState
Application: PreUpdateRequestCache
Application: UpdateRequestCache
Application: PostUpdateRequestCache
Application: EndRequest
Application: PreSendRequestHeaders
Application: PreSendRequestContent
http://www.geekinterview.com/question_details/22673

- 5/29/2010
- grantph
- 4/14/2011
- Miles Gibson
Folks,
According to MSDN in 2009:
ASP.NET Page Life Cycle Overview
Page request
The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
Start
In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Additionally, during the start step, the page's UICulture property is set.
Page initialization
During page initialization, controls on the page are available and each control's UniqueID property is set. Any themes are also applied to the page. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.
Load
During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state.
Validation
During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.
Postback event handling
If the request is a postback, any event handlers are called.
Rendering
Before rendering, view state is saved for the page and all controls. During the rendering phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page's Response property.
Unload
Unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed.
Now in 2011:
ASP.NET Page Life Cycle Overview
Page request
The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
Start
In the start stage, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. The page also sets the UICulture property.
Initialization
During page initialization, controls on the page are available and each control's UniqueID property is set. A master page and themes are also applied to the page if applicable. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.
Load
During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state.
Postback event handling
If the request is a postback, control event handlers are called. After that, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.
Rendering
Before rendering, view state is saved for the page and all controls. During the rendering stage, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream object of the page's Response property.
Unload
The Unload event is raised after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and cleanup is performed.
Can anyone please clarify whether ASP.NET Page Life Cycle Validation stage occurs before or after Postback event handling?
Thanks
[Tom Dykstra - MSFT] The current version of the page is correct.
According to MSDN in 2009:
ASP.NET Page Life Cycle Overview
Page request
The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
Start
In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Additionally, during the start step, the page's UICulture property is set.
Page initialization
During page initialization, controls on the page are available and each control's UniqueID property is set. Any themes are also applied to the page. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.
Load
During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state.
Validation
During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.
Postback event handling
If the request is a postback, any event handlers are called.
Rendering
Before rendering, view state is saved for the page and all controls. During the rendering phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page's Response property.
Unload
Unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed.
Now in 2011:
ASP.NET Page Life Cycle Overview
Page request
The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
Start
In the start stage, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. The page also sets the UICulture property.
Initialization
During page initialization, controls on the page are available and each control's UniqueID property is set. A master page and themes are also applied to the page if applicable. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.
Load
During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state.
Postback event handling
If the request is a postback, control event handlers are called. After that, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.
Rendering
Before rendering, view state is saved for the page and all controls. During the rendering stage, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream object of the page's Response property.
Unload
The Unload event is raised after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and cleanup is performed.
Can anyone please clarify whether ASP.NET Page Life Cycle Validation stage occurs before or after Postback event handling?
Thanks
[Tom Dykstra - MSFT] The current version of the page is correct.
Category: ASP.NET QUE
0 comments