I have an Ascx control which I reload every Page_load using Loadcontrol.
This Ascx has a Button And Label
The Label initially contains “aaa“.
When I click the button the page reloads and recreates the ascx.
The good thing is that the "aaa" is kept – although it’s a new instance of the ascx.
I was wondering to my self why ? and I’ve answered to myself that’s its because the ID of the ASCX which is the same so he is attaching the viewstate from the last postback to the current instance.
Question
What is the latest page event which I can create the control
so that it will be able to attach the viewstate (from the last postback)to the new generated control ?
Following are the events occur during ASP.NET Page Life Cycle:
Among above events Page_Render is the only event which is raised by page. So we can’t write code for this event.