OnPreRender ??? What is ?

D

Daniel Groh

Hi, i'd like to know more abou this event, i tryed to found in MSDN but the
explanation is null for me...is there some explanation when and how should i
use it ?
 
S

Scott M.

Pre-render isn't an event, it's a "stage" that a page instance goes through
Page_Init and Page_Load both occur during this stage.
 
D

Dave Fancher

OnPreRender is indeed an event raised as part of the page life-cycle. The
page's OnPreRender method may be overridden or a delegate may be used to
define an Event Handler in a manner similar to Page_Load and Page_Init.

[C#]
protected override void OnPreRender(System.EventArgs e)
{
// PreRender code
base.OnPreRender();
}

or
this.PreRender += new System.EventHandler(Page_PreRender);

OnPreRender is typically used for handling some last minute tasks such as
enabling or disabling controls or modifying other content after control
events have been handled but before the viewstate is saved and the HTML is
rendered [generated].

I'll refer you to
http://msdn.microsoft.com/library/d.../en-us/dnaspp/html/aspnet-pageobjectmodel.asp
for more information about the life cycle of an ASP.NET page.

HTH
 
M

Mark Broadbent

just to say what Dave has said in another way (this from a ref book) "The
PreRender event is raised just before the page is about to render its
contents. This is the last chance to modify a page output before it is sent
to the browser".
 
G

Guest

OnPreRender is NOT the event, it's the method that raises the PreRender event.

and scott, Page_Load and Page_Init do NOT get called during the PreRender
phase. They are event handlers wired up to the Load and Init events
respectively.

PreRender is the last place you can change your control states before Render
is called recursively to generate the HTML output of a page. If you do a lot
of custom server controls, this is typically where you would register client
side javascripts among other things.

Dave Fancher said:
OnPreRender is indeed an event raised as part of the page life-cycle. The
page's OnPreRender method may be overridden or a delegate may be used to
define an Event Handler in a manner similar to Page_Load and Page_Init.

[C#]
protected override void OnPreRender(System.EventArgs e)
{
// PreRender code
base.OnPreRender();
}

or
this.PreRender += new System.EventHandler(Page_PreRender);

OnPreRender is typically used for handling some last minute tasks such as
enabling or disabling controls or modifying other content after control
events have been handled but before the viewstate is saved and the HTML is
rendered [generated].

I'll refer you to
http://msdn.microsoft.com/library/d.../en-us/dnaspp/html/aspnet-pageobjectmodel.asp
for more information about the life cycle of an ASP.NET page.

HTH
----------------
Dave Fancher
http://www.davefancher.com

Scott M. said:
Pre-render isn't an event, it's a "stage" that a page instance goes
through Page_Init and Page_Load both occur during this stage.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top