在页生命周期渲染事件 [英] Render event in Page Life Cycle
问题描述
我有以下文件在我的项目文件中。
I have a following files in my project file.
- 用户控制
- 内容页
- 网站主
我在检查页面生命周期的渲染
事件。 渲染
在以下顺序执行事件。
I was checking the page life cycle for Render
event. Render
event is being executed in following order.
- 内容页
- 母版页
- 用户控制
显然,这是pdefined $ P $。
Obviously, It is predefined.
问是,为什么内容页,然后母版页和最后用户控制?
Question is, why the content page then Master Page and finally User Control?
我的意思是如何完整的HTML被合并到发送给浏览器?难道不应该首先包含母版页?
I mean how the complete Html is being merged to sent to Browser? Shouldn't it contain Master Page first?
推荐答案
渲染不是一个事件。它是一个被称为以产生输出到发送到客户端的方法。结果,
渲染渲染本身和它的孩子。
Render is not an event. It is a method called to generate the output to send to the client.
Render renders itself and its children.
的顺序
给予
RenderChildren
The order is Render RenderChildren
由于可以清楚地在 ASP可以看出.NET页面生命周期。
在你的控制层次,页面是父。母版是页面控件的子。根据你在哪里放置用户控件,这将是本页面或母版的一个孩子。
In your control hierarchy, page is the parent. MasterPage is a child of the Page control. Depending on where you have placed your user control, it will be a child of either the Page or MasterPage.
如果您创建一个自定义的控制,通常重写此方法以输出控件的标记
If you create a custom control, you typically override this method to output the control's markup
每个控制从其父收到的HtmlTextWriter
和它的输出写入此作家。客户端收到的最终输出是控制和它的所有儿童作家写的输出。
Each control receives a HtmlTextWriter
from its parent and writes its output to this writer. The final output received by the client is the output written by control and all its children to writer.
由于页有启动这个过程中,它的渲染已被首先调用。
Since the page has to start this process, its Render has to be called first.
这篇关于在页生命周期渲染事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!