Reputation: 1521
I wonder what is processed first: if the code placed in the aspx part (using server tags <% %>) or the code behind, because I place a variable that is filled in the Page_Load in the aspx between server tags and I'm not getting anything when there is a value.
Anyone can point me in some directions like an article talking about the page lifecycle that includes the aspx code?
Thanks!
Upvotes: 1
Views: 1067
Reputation: 566
When HttpHandler calls ProcessRequest() method, it starts with creating a Autogenerated class from .aspx file. This autogenerated class will create page's control hierarchy for .aspx page which is just converting declarative syntax into actual code in C# or VB. This autogenerated class is then combined with partial code behind class. Now this completed class will serve as base class to .aspx page. This class is stored inside \WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files. And this class will server all the request for the page. So if you have any Protected/public variable declared inside partial code behind class and you populate that variable with some value in Page_load, and if you wants to print on .aspx page using <%=variablename %>, it should print the value which is assigned in Page_Load on web page.
Upvotes: 1
Reputation: 74176
From MSDN: ASP.NET Page Life Cycle Overview
(http://msdn.microsoft.com/en-us/library/ms178472.aspx)
Upvotes: 2
Reputation: 52460
As the other poster says, there's a documented lifecycle.
That aside, the codebehind represents the base class, the aspx the derived class. The markup in the ASPX is actually compiled into native code, so the true answer is that the page and the codebehind are essentially one instance, since the compiled ASPX inherits the Page-derived code in the codebehind.
-Oisin
Upvotes: 1