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

岁酱吖の 提交于 2019-12-02 04:25:42

问题


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


回答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.



来源:https://stackoverflow.com/questions/15209500/in-asp-net-do-inline-expressions-get-executed-before-or-after-the-code-behind

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