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

前端 未结 1 1458
伪装坚强ぢ
伪装坚强ぢ 2021-01-21 23:31

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

相关标签:
1条回答
  • 2021-01-22 00:15

    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.

    0 讨论(0)
提交回复
热议问题