page_PreRender事件有什么作用? [英] What does page_PreRender event do?

查看:103
本文介绍了page_PreRender事件有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

page_PreRender事件有什么作用?在什么情况下我们会使用它?谁能解释一下?我读了一些文章,但我听不懂.页面渲染实际上是什么?任何人都可以解决我的问题吗?

What does page_PreRender event do? Under which circumstances do we use it? Can anyone please explain? I have read some articles but I did notunderstand. What is page rendering actually? Can anyone solve my problem please?

推荐答案

Page 对象在树型层次结构中由Controls组成.每个控件都呈现其特定的HTML 标记.因此,当执行和渲染Page 对象时,它通过递归调用其Control 树层次结构中每个Control 的渲染动作来渲染整个HTML HTML.

现在,由于某种原因,您可能希望在渲染发生之前的最后一刻修改Page对象的渲染HTML.因此,Asp.net使您有机会通过创建Page_PreRender()事件处理程序来修改HTML .如果在aspx 页面的CodeBehind中添加此事件处理程序,Asp.net运行时将在呈现页面HTML之前执行此方法,以便您可以在Page_PreRender()方法中自定义HTML.
The Page object is composed of Controls, in a tree hierarchy. Each control renders its specific HTML markups. So, when a Page object is executed and rendered, it renders the overall HTML by recursively calling the render action of each and every Control in it''s Control tree hierarchy so that they also renders their own HTML.

Now, for some reason, you may wish to modify the rendered HTML of the Page object at the last moment, before rendering occurs. So, Asp.net gives you the opportunity to modify the HTML by creating a Page_PreRender() event handler. If you add this event handler in the CodeBehind of your aspx page, Asp.net runtime will execute this method before rendering the page HTML, so that you can customize the HTML within the Page_PreRender() method.


Page Load : Perform actions common to all requests, such as setting up a database query. At this point, server controls in the tree are created and initialized, the state is restored, and form controls reflect client-side data. See Handling Inherited Events.

Prerender :Perform any updates before the output is rendered. Any changes made to the state of the control in the prerender phase can be saved, while changes made in the rendering phase are lost. See Handling Inherited Events.


这篇关于page_PreRender事件有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆