473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Tricky Question: Page_Load

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
Nov 17 '05 #1
3 2542
You could take the code out of page_load and put it into page_prerender.
Then it will run after all your controls preload

"VB Programmer" <gr*********@go-intech.com> wrote in message
news:uS**************@TK2MSFTNGP11.phx.gbl...
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

Nov 17 '05 #2
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

"VB Programmer" <gr*********@go-intech.com> wrote in message
news:uS**************@TK2MSFTNGP11.phx.gbl...
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

Nov 17 '05 #3
This worked GREAT! Thanks!

"charles" <ch*****@synthigence.com> wrote in message
news:eR**************@tk2msftngp13.phx.gbl...
You could take the code out of page_load and put it into page_prerender.
Then it will run after all your controls preload

"VB Programmer" <gr*********@go-intech.com> wrote in message
news:uS**************@TK2MSFTNGP11.phx.gbl...
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


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JZ | last post by:
Oracle 9iR2 I have a table: SQL> select * from test; A B C ------------------- ---------- ---------- 01/01/2004 10:00:00 1 1...
25
by: PyPK | last post by:
What possible tricky areas/questions could be asked in Python based Technical Interviews?
8
by: pras.vaidya | last post by:
Hi , below given question was asked to me during an interview and i figured it out little tricky . It would be a great help if anyone could solve it. Code : - main() { char...
7
by: Matt | last post by:
Hello, In an aspx page i have webform with some textboxes and a simple button. When the button is clicked, there is a postback and then the code in the click event of the button is executed. ...
8
by: Steve Klett | last post by:
This is probably a commonly asked question, but I can't find a good way to search for it, so I will ask here. I assumed that there had to be an easy way to access a page level variable from a...
6
by: Bill Jones | last post by:
I'm trying to use this.RegisterStartupScript to add some javascript to and aspx page that will run when the page is loaded. Does anyone know if this function only works in the Page_Load function? ...
3
by: Harry | last post by:
Dear all, It is found that when a webform control trigger an event, Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub This...
9
by: Robert Galvin | last post by:
Is it possible to tell which control caused a postback?
12
by: Bishoy George | last post by:
I have a dataset called ds1 filled with 2 tables Employees and Customers from Northwind database. I have dropdownList called ddLastName with the following properties: ddLastName.DataSource =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.