- Each page in ASP.NET 2.0 or upper has the AutoEventWireup tag set to true, which means that all this page initialization events are type by yourself.
protected void Page_PreRender(object sender, EventArgs e) {
// your code goes here
}
This content is copied from [1]. Many thanks to the author of the article.
In this article, we will explore the various events that occur when an asp.net 2.0 page is requested from the server. Before exploring that, let us briefly take a look at the various components that participate in the request and response model for asp.net pages.
When a request is made to the server using HTTP (GET), IIS receives the request and passes it to the asp.net engine(dll) that compiles the page that is requested. The request passes through two sections :
Http Module – Monitors the request and takes action. Authentication and Authorization take place over here.
Http Handler – Responsible for compiling the page and generating output using System.Web.UI.PageHandlerFactory (we are considering .aspx page for this article).
Once compilation is done, the page is sent back to the Http module which then sends it to the IIS and back to the browser.
The events occur in the following sequence. Its best to turn on tracing(<% @Page Trace=”true”%>) and track the flow of events :
PreInit – This event represents the entry point of the page life cycle. If you need to change the Master page or theme programmatically, then this would be the event to do so. Dynamic controls are created in this event.
Init – Each control in the control collection is initialized.
Init Complete* - Page is initialized and the process is completed.
PreLoad* - This event is called before the loading of the page is completed.
Load – This event is raised for the Page and then all child controls. The controls properties and view state can be accessed at this stage. This event indicates that the controls have been fully loaded.
LoadComplete* - This event signals indicates that the page has been loaded in the memory. It also marks the beginning of the rendering stage.
PreRender – If you need to make any final updates to the contents of the controls or the page, then use this event. It first fires for the page and then for all the controls.
PreRenderComplete* - Is called to explicitly state that the PreRender phase is completed.
SaveStateComplete* - In this event, the current state of the control is completely saved to the ViewState.
Unload – This event is typically used for closing files and database connections. At times, it is also used for logging some wrap-up tasks.
FreeTextBox
Providing a Richer Means for Entering Text Data
The issue is represented in the useful article [2]. We want to have Browse... button to select an image for inserting in a document.FreeTextBox
Providing a Richer Means for Entering Text Data
FreeTextBox: http://forums.aspfree.com/net-development-11/freetextbox-imagegallery-213698.html
http://www.websitebabble.com/web-design-development-software-including-cms/3848-asp-net-freetextbox.html
References:
[1] ASP.NET 2.0 Page Event Life Cycle, http://www.dotnetcurry.com/ShowArticle.aspx?ID=83&AspxAutoDetectCookieSupport=1, retrieved 14/08/2010
[2] Providing a Richer Means for Entering Text Data, http://www.4guysfromrolla.com/articles/102004-1.aspx, retrieved 15/08/2010
http://infinitiesloop.blogspot.com/2006/03/truly-understanding-viewstate.html
ReplyDeletehttp://bytes.com/topic/asp-net/answers/515134-access-viewstate-page-init
ReplyDeletehttp://www.thaicreate.com/asp.net/c-sharp-asp.net-detailsview-gridview-control-visual-studio-2005-framework2.0.html
ReplyDeletehttp://forums.asp.net/p/1446283/3412448.aspx
ReplyDeletehttp://www.codeproject.com/KB/viewstate/AccessViewState.aspx
ReplyDeletehttp://www.codeproject.com/KB/aspnet/aspnetviewstatepagecycle.aspx
ReplyDeletehttp://www.beansoftware.com/ASP.NET-Tutorials/ViewState-In-ASP.NET.aspx/
ReplyDelete