Share Information Among a Page and its UserControls?

A

Axel Dahmen

I need to share complex data across a page and its Web user controls. Can
someone please enlighten me on how to do this?


My approach doesn't work:

* Create a class,

* add a public reference to that class to the ASPX page and all the Web user
controls (WUCs),

* in the Page's Init() event, create an object of the class, set all its
members and set all the WUCs' references to this object,

* access the object from any of the references.


This and similar approaches (e.g. using only one public reference in the
Page and access it from the WUCs) don't work because the WUCs' Init() event
are called before the Page's Init() event, so I can neither create an object
nor initialize any reference at this central point.

The data to be shared across the WUCs comes from the database, hence it's
quite expensive to create a distinct object from within each of the WUCs. I
can't also use the Load() events because I use the class's data to
dynamically create controls in the WUCs.

Any ideas?

TIA,
Axel Dahmen
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top