In ASP.NET, do inline expressions get executed before or after the code behind?

Do ASP inline expressions <% ... %> get run on the server before or after the code in the code-behind is executed?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Inline code executes after prerender page in the asp.net page life cycle. Because of this there are certain things that it can run before and certain things it can run after. Read up on the page life cycle here:

http://msdn.microsoft.com/en-us/library/ms178472(v=vs.100).aspx

The events that come after prerender are:

  • PreRenderComplete
  • SaveStateComplete
  • Render
  • Unload

So any code in the other page lifecycle events will execute first.

From Microsoft’s documentation:

An embedded code block is server code that executes during the page’s
render phase.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x