Accessing Page Property From User Control

Joined
Nov 10, 2006
Messages
2
Reaction score
0
I have a base page class (BasePage) that all pages on my site inherit.

I also have a database abstraction class (DBClass) that I use to handle all interaction with my database. I have it set up so that when you create an instance of DBClass, it creates a connection to the database, and then all methods on that instance of DBClass use that connection to interact with the database.

So, my idea was to create a public property DB of BasePage that is an instance of DBClass. That way, the database connection will be open and available when the page is initialized and I should be able to make use of it for any calls to the database I might want to make while creating the page.

So far so good (although if you see any problems with the logic so far, please let me know).

However, now I have the following issue: I have a User Control defined on the page that has to make use of the database. I don't want to create a *new* instance of DBClass inside that user control; it seems like it would be better to just use the public property DB of the main page, that was already created.

But I can't figure out how to reference the property DB from inside the user control.

Any help or insight would be greatly appreciated.

------G
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top