Part of the .NET infrastructure that provides a programming model and various services to build web applications
ASP.NET Web Forms
Provides a higher level of abstraction compared to the request/response approach and HTML creation
Uses ViewState to transfer state information between the browser and server
ASP.NET Page Lifecycle Stages
1. PageRequest
2. Start
3. Initialization
4. Load
5. PostbackEventHandling
6. Rendering
7. Unload
ASP.NET Page Lifecycle Events
PreInit
Init
InitComplete
PreLoad
Load
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
Types of ASP.NET server controls
HTML server controls
Web server controls
Validation controls
User controls
ASP.NET has a powerful set of built-in server controls that provides a boost in development speed and enhance rapid application development
ASP.NET server controls are items that a developer places on an ASP.NET web page
Many ASP.NET server controls are similar to HTML elements, while others allow for more complex behavior such as calendar and data connection controls
ViewState
The response to change in the page content is enhanced through the use of ViewState. ViewState is how ASP.NET Web Forms take this customized approach and transfer state information between the browser and the server.
The ASP.NET lifecycle allows the developer to interact with information at various points in the HTML creation phase.
Page Request
This stage happens before the page-calling process starts. It is when the system determines whether run-time compilation is necessary, whether cached output can be returned, or whether a compiled page needs to be run.
Start
The page starts to do some processing on the HTTP request. Some base variables are initialized, such as Request, Response, and the UICulture.
Initialization - During this phase, the controls on the page are initialized and assigned their unique IDs. Master pages and themes are applied as applicable.
Load - if the request is a postback, control information is loaded with the information recovered from the view state.
Postback Event Handling - If the request is a postback, all the various controls fire their event handlers as needed. Validation also happens at this time.
Rendering - Before the rendering stage starts, ViewState is saved for the page and all of the controls as configured.
Unload - This happens after the content is created and sent to the client. Objects are unloaded from memory and cleanup happens.
PreInit - Raised after the start stage is complete and before the initialization stage begins. It is used to create or recreate dynamic controls, setting master pages or themes dynamically.
Init - This event is raised after all the controls have been initialized. It is used to initialize control properties.
InitComplete - Only one thing happens between Init and InitComplete, and that is the enabling of view state for the controls. Changes applied in this event and after will impact view state to make sure it will be available next postback.
PreLoad - Raised after the page manages the view state information for itself and all controls.
Load - The OnLoad method is called in a page, which then recursively calls that same method on every control.
Control Events - These are specific control-based events, such as the Click of a button, or TextChanged on a text box.
LoadComplete - This event is raised after all the event handling has occured.
PreRender - After all the controls have been loaded, the Page object starts its Prerender phase.
PreRenderComplete - Raised after every data-bound control has been bound.
SaveStateComplete - Raised after view state and control state have been saved for the page and for all controls.
Render - this is not an event. Rather, at this point in the process, the Page object calls this method on each control.
Unload - This is used to perform special cleanup activities, such as closing files or database connections, logging, etc.
HTML server controls - wrappers for traditional HTML elements.
Web server controls - tends to encompass more functionality and be more abstract than an HTML server control.
Validation controls - ensures that the values entered into other controls meet certain criteria, or are valid.
User controls - controls that you build yourself. If a set of functionality needs to be available on multiple pages, then it is most likely that you should create this functionality as a user control.
Web Forms Server Control
Add-ins to the markup section of the application, which are added to HTML documents. Elements added to an .aspx file used for displaying the properties, methods, and events that can be accessed by the code-behind file.
Server controls
Designed to give support for the user interface; they are generally called in the HTML.
Types of Web Forms Server Controls
Standard Controls
HTML Controls
Data Controls
Validation Controls
Navigation Controls
Login Controls
Standard Controls
Built-in controls in ASP.NET that are used to display information to the user. Some act as simple wrappers for HTML elements.
HTML Controls
Act as wrappers around HTML elements, giving the developer access to the content as well as many of the attributes of the base HTML element.
Data Controls
Controls designed to help enter, access, and display data on a web page.
Validation Controls
Enable you to check the values of other controls to ensure that their content matches the expected format of data.