asp.net: what's the page life cycle order of a control/page compared to a user contorl inside it?
Asked Answered
P

2

34

I have an aspx and inside it an ascx. From a short testing I see the PageLoad of the aspx is called before the PageLoad of the user-Control but the opposite is true for OnInit.

Does someone know what is the order of the events (page compared to a user-control inside it)

Thanks

Passivism answered 7/9, 2011 at 13:59 Comment(0)
J
90

You should look at this ASP.NET Page Life Cycle Overview and this

Page: PreInit
Control: Init
Page: Init
Page: InitComplete
Page: PreLoad
Page: Load
Control: Load
Page: LoadComplete
Page: PreRender
Control: PreRender
Page: PreRenderComplete
Page: SaveStateComplete
Page: RenderControl
Page: Render
Control: RenderControl
Control: Unload
Control: Dispose
Page: Unload
Page: Dispose

Jehovah answered 7/9, 2011 at 14:8 Comment(10)
Good resource, but it's encouraged for you to summarize some info / asnwer the OP's question in the Answer you've posted. Just in case the link ever dies, this information will be there for future searchersMonometallism
I have ready your first link. I ask about the order of the events of the page compared to the events of the control inside it.Passivism
I've updated the answer with more details. Is that what you want?Jehovah
amazing! Does it also appear in the links you have posted? If not- where did you take it from?Passivism
I get it from.. my bookmarks. Application, Page and Control events in ASP.NET v2.0Jehovah
same logic for a user-control inside another user-control ?Passivism
Missing LoadViewState check msdn.microsoft.com/en-us/library/aa719775%28v=vs.71%29.aspxSandysandye
@EladBenda ASP.NET Page Life Cycle Overview says, "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."Sighted
Missing control Page_loadHydrometeor
SaveViewState is also missingFalito
R
3

below link has more information

http://weblogs.asp.net/ricardoperes/archive/2009/03/08/asp-net-page-events-lifecycle.aspx

Romanesque answered 14/11, 2013 at 5:45 Comment(1)
Link only answers are discuraged by the site policy. Please, take time to extract the relevant information and add it to the question, since the URL can break at any time and this answer will lose it's value.Oddson

© 2022 - 2024 — McMap. All rights reserved.