sharing data between custom controls

  • Thread starter Thread starter axis
  • Start date Start date
A

axis

I have two custom controls on a page that work on the same object that needs
some prepping when first loaded. Currently I just load them in both controls
individually, essentially doing the same work twice.

What's the best way to share data between controls? I know I could place the
data in HttpContext, but would I essentially be tripling the amount of
memory I'm using? 1 copy in control1, 1 copy in context, and 1 copy in
control2. Unless context works by reference. Otherwise, is there a better
way? The controls inherit from a common class already -- is there any way to
have a variable in that parent class that is shared within a page?

Thanks
 
BTW -- there's no need to persist the data after the page is rendered. Sorry
I didn't clarify this. It's just data used while rendering the controls. The
data is needed by various controls.
 
Create the object at the page level and pass it to both controls.
 

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

Back
Top