In ASP.Net, during which page lifecycle event does viewstate get loaded?

时光怂恿深爱的人放手 提交于 2019-11-29 20:19:57

It's loaded into memory between init and load. See this article for a full break down of the page lifecycle.

I once got into this question too and got my answer from TRULY understanding Viewstate article, which I highly recommend.

After reading it I designed a graphic that helped me to understand better what was happening on between each stage and when and how ViewState was doing its job.

I'd like to share this graphic with other people that (like myself) need to see how stuff work in a more visual way. Hope it helps! :)

Click on the image to view at full width.

That is to say, viewstate is loaded between the OnInit() and OnLoad() events of the page.

My favorite article on dealing with viewstate, which answers every question I have every time: http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx

You can see from the page life cycle as explained on MSDN

That the view state is loaded during the Load phase of the page lifecycle, i.e. the LoadViewState method of the "Page methods" and the LoadViewState method of the Control methods, above.

The Viewstate is actually loaded in the OnPreLoad event of the page,Just after the Page_InitComplete.

The viewstate is actually loaded between initComplete and Preload events.Check this for details http://msdn.microsoft.com/en-us/library/ms178472.aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!