I have a page and few controls. I’m doing a normal postback.
On InitializeCulture event of the page the Page.Request object contains e.g. controls with their values – and that’s great.
But on the other hand, when I’m trying to access this collection on the Page_Load or OnInit events, it’s way smaller and doesn’t have any of the controls that have been there before.
Can anyone tell me what happens with Page.Request between these events?
EDIT:
Thanks guys, I was aware of the Page Life cycle term:) and these links were indeed helpful.
I probably haven’t pointed that out clearly , but:
- inside override method for InitializeCulture() I Page.Request is full of various controls. Right after calling the base.InitializeCulture() , Page.Request has only server variables. I could look for values of my controls here, but can’t do it – the controls are not initialized yet (so calling Request.Params.Get(SomeControl1.UniqueID) throws error)
- overriding PreInit, Init or Page_Load doesn’t help at all.
So the question is what and when happens with Page.Request between InitializeCulture() and next events that makes it smaller?
Btw. I find http://i.msdn.microsoft.com/dynimg/IC386473.png a much better illustration of Page Life Cycle.
EDIT:
What a mistake. Someone was doing a redirect which was resetting the whole Request collection… Lame of me. I would delete this post, but cannot.
Basic page life cycle will answer your question
Full article: http://www.codeproject.com/KB/aspnet/ASPDOTNETPageLifecycle.aspx
(source: codeproject.com)
Image Source: ASP.NET application and page life cycle, by Shivprasad Koirala, 19 April 2010