I am working with C# web application. I want to know deeply about the page events. Because I thought that the page load event happens first (when a page is requested in browser). But when I tried with commenting the method protected void Page_Load(object sender, EventArgs e)
the page get loaded without error.
Your web form has a method called Page_Load. This method is called each time your page is loaded. This includes: 1. The first time the page is loaded, e.g., when a user enters the url to it or clicks on a link to it.
Page_Load Event This event occurs only after Page_Init event and this event also will raise for every postback operation and in this stage all control properties are loaded with information recovered from view state and control state.
Page_Load() method is called after a preLoad event.
Load. 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.
off-course your webpage will work even if there is no Page_Load() method. Before a Page_Load() events like PreInit, Init() etc are called. Refer to page life cycle.
Page_Load() method is called after a preLoad event. With Page_Load() you can set default values or check for postBacks etc.
protected void Page_Load(object sender, EventArgs e)
{
int x = 10;
}
write this and put a break-point on int x = 10; watch sender and e.
Every Page object has nine events
, most of which you will not have to worry about in your day to day dealings with ASP.NET. The three that you will deal with the most are:
Page_Init
Page_Load
Page_PreRender
They do execute in the order given above so make sure to take that into consideration, especially when building custom controls. The reason you have to keep this in mind is because information might not be available when you expect if you do not deal with it appropriately.
Refer: Life Cycle
1.Page request
2.Start
3.Initialize
4.Load
5.Postback Event Handling
6.Rendering
7.Unload
This is the page life cycle.
Load event comes at 4th position.
You can check details over here:
http://msdn.microsoft.com/en-us/library/ms178472%28v=vs.100%29.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With