Last post Nov 27, 2017 02:13 AM by Cathy Zou
Nov 24, 2017 09:33 AM|Wonderous|LINK
Is it not okay to render the complete page and then do all the modifications?
Why do we need to have so many page life cycle events?
Nov 24, 2017 09:57 AM|PatriceSc|LINK
You are using Web Forms? You may want to be more explicit. It is an old programming model who was designed to be familiar to Windows desktop developers (ie having controls with events).
If you want you have MVC which is closer to how the web really works.
Help you'll have to be more explicit about the exact problem. "render the complete page and then do all the modifications" is quite vague. You have to distinguish what happens on the server side or the client side. Or you want to build a "single page application"
Nov 24, 2017 10:44 AM|Wonderous|LINK
Thanks for the response.
Here is the address which presents all the stages of Page Life Cycle. What I am asking is: why is it not okay to have only Page_Load( ) event? I have this single stage occurring on server.
When the page is ready at the server which is to be sent as response to the user I can perform, lets say: CSS changes on this final stage. Why do we need to have so many stages that we call Page Life Cycle stages.
Do you have an example that demonstrate the use of Page Life Cycle events?
Nov 24, 2017 12:00 PM|PatriceSc|LINK
It's even worse than that if you look at the life cycle of a web request but you'll mostly use Load, maybe be PreRender and control level events such as click (for example you'll use Init only if you need to create controls dynamically so that those controls
are correctly handled during the next steps).
Before looking at this in details I would suggest to have a look at
https://docs.microsoft.com/en-us/aspnet/web-forms/overview/presenting-and-managing-data/model-binding/retrieving-data which should be simpler and closer from MVC or Razor web pages.
I would suggest to consider using this "model binding" approachj rather than the initial fully event driven model (the intiial intent was IMO really to "ease" stuff when most developers were not familiar at all with the web).
Nov 27, 2017 02:13 AM|Cathy Zou|LINK
ASP.NET Page Life Cycle order and events Page life cycle is very important concept to understand while working with asp.net, what are the stages we can read the view state values and what is the last event where can write back our view state again. When
to load the dynamic controls and when to check the values of dynamically added controls, It is impossible to work without knowing the basics of page life cycle
While developing custom controls, we 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.
Page cycle helps in writing codes for making some specific thing happen at any stage of the page life cycle. It also helps in writing custom controls and initializing them at right time, populate their properties with view-state data and run control behavior
Related articles and example for reference, please check the links below: