Reputation: 11
i was trying to find the sequence of event between Master page and aspx page. I came to know that unload event of master page calls before then unload event of ASPX page.
I already read this in many websites but i am looking for reason behind it. If someone has an idea about this then kindly help me.
Upvotes: 1
Views: 1410
Reputation: 10565
One good reason I found is this::
Master pages behave like child controls on a page.
What this means is that the way any Control events are raised by the Asp.Net page life cycle, same way it will raise events for Master pages.
Consider for example, the Init event
. MSDN says that the Init event of individual controls occurs before the Init event of the page. And thus, the Init event of Master page occurs before the Init event of page.
One more example, consider the Load event
.MSDN says that the Load event of individual controls occurs after the Load event of the page. Therefore the Load event of Master page occurs after the load event of content page.
This is indeed confirmed by MSDN
::
Master pages behave like child controls on a page: the master page Init event
occurs before the page Init and Load events, and the master page Load event
occurs after the page Init and Load events
So, now you can say that the way Unload event is raised for controls, it will be same for master page.
The Unload event is raised for each control first and then for the page. So this is the reason why Unload event of master page is called before Content page.
Upvotes: 1