page_prerender...when/why to use?

  • Thread starter Thread starter Darrel
  • Start date Start date
D

Darrel

I'm finding references to the use of page_prerender. How does this differ
from page_load?

I've had some issues in the past with setting cookies and then adjusting the
page based on the saved cookie. This is the route I've had to take:

page_load
- read cookie
click button
post back
page.isPostback
grab new values
write cookie
redirect to self

The (minor) problem is that the page executes 3 times: read, write, read new
settings. Would page_prerender help with the above issue at all?

-Darrel
 
My question is - if the code knows what value it is going to write
into the cookie - why do you need to wait for a post back to read the
value?
 
Scott Allen said:
My question is - if the code knows what value it is going to write
into the cookie - why do you need to wait for a post back to read the
value?


It's a preference setting, so the order is this:

various controls read the cookie
set the preference widgets to the default value
allow the user to change the widgets
sumbit
rewrite cookie
reload page and read the new settings.

The issue is that there are other userControls dependant on this cookie. So
if I just do the post back, then yes, the current widgets are preserved from
the postback. But since the cookie isn't WRITTEN until the postback, other
controls on the same page don't get the updated value unless the end-user
hits reload.

Hence the need for the redirect.

I hope that made sense ;o)
 
Hi Darrel:

You could catch PreRender and tweak the properties of each control -
that is the spot to make any final adjustments to the control
properties before display.

Something else you might want to think about is adding the user
controls as member varialbes to your page class and trying to set the
properties without the redirect. You should be able to do this, if I
understand your description.
 
Thanks, Scott...will look into that!

-Darrel

Scott Allen said:
Hi Darrel:

You could catch PreRender and tweak the properties of each control -
that is the spot to make any final adjustments to the control
properties before display.

Something else you might want to think about is adding the user
controls as member varialbes to your page class and trying to set the
properties without the redirect. You should be able to do this, if I
understand your description.
 

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

Back
Top