Tricky Question: Page_Load

  • Thread starter Thread starter VB Programmer
  • Start date Start date
V

VB Programmer

I have a usercontrol that sets a public/shared variable called
"database_name". (User selects a dropdownlist of available databases.) A
webform (webform1), that uses this usercontrol, connects to the database
defined by that public variable and does stuff.

Problem: Webform1 is always one database "behind". This is because the
Page_Load runs on webform1, THEN Page_Load is run on the usercontrol (which
sets the database_name variable).

Any ideas how I can fix this/compensate?

Please assist.

Thanks,
Robert
 
You don't want to put any actually "processing" functionality into page
load. You should be doing any processing in an event such as a click, that
way all controls (both user and asp) have a chance to run their load event.
The data for the controls in the page_load isn't guaranteed to be up to
date.

HTH,

bill
 
You could take the code out of page_load and put it into page_prerender.
Then it will run after all your controls preload
 
This worked GREAT! Thanks!

charles said:
You could take the code out of page_load and put it into page_prerender.
Then it will run after all your controls preload
 
Back
Top