控件的页面生命周期(从页面构造的顺序)
例如,假设我有一个页面和该页面上的 2 个自定义控件。在页面上的什么事件期间构建这些控件。他们的 page_init 什么时候被调用?
另外,对于这两个自定义控件,它们是否都是在调用 page_init 事件之前构造的?
我已经使用调试器等进行了一些测试,但我想要这些问题的明确答案。我不想编写仅有时有效的代码。
For example, lets say I have a page and 2 custom controls on that page. During what event on page do these controls get constructed. When does their page_init get called?
Also, for these 2 custom controls, do they both get constructed before either of the page_init events get called?
I've done some testing with a debugger and such, but I'm wanting a definite answer to these questions. I'm not wanting to make code that works only sometimes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文档中的官方页面详细描述了页面生命周期,但是一张图片胜过一千个单词:
如果我理解正确的话,控件是在页面的
PreInit
和Init
之间构造的。因此,控件的Init
方法在页面的Init
方法之前调用。根据架构,
Construct
和FrameworkInitialize
在每个控件上在Init
之前调用> 事件被触发,这意味着在进入特定控件的Init
方法时,所有控件都应该被构造并可用。The official page in the documentation describes the page lifecycle in details, but a picture is worth a thousand words :
If I understand correctly, controls are constructed between the
PreInit
andInit
of the page. Thus, controls'Init
methods are called before the page'sInit
method.According to the schema,
Construct
andFrameworkInitialize
are called on each control before theInit
event are fired, which means that all controls should be constructed and available when entering a specific control'sInit
method.