Tricky Question: Page_Load

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
 
W

William F. Robertson, Jr.

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
 
C

charles

You could take the code out of page_load and put it into page_prerender.
Then it will run after all your controls preload
 
V

VB Programmer

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
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top