How to grab a variable from a user control from the parent page

D

Darrel

I have a usercontrol that sets some public variables.

I can grab this variable from another usercontrol like this:

ctype(Page, templatePage).UC_getVariables.globalMenuCategory

This works fine because the control setting the variable is processed before
the control reading the variable.

The catch is that I now want to read this variable from the parent page. The
issue is that the parent page code is executed PRIOR to the userControl that
sets the variable. So I'm not returning a value.

Is there any way around this? If not, I'm guessing the solution is to simply
migrate the UC code that sets the variables into my parent page's
codebehind.

-Darrel
 
M

Mark Fitzpatrick

Darrel,
Make sure that any calculations or things that are going on in the
control are not done in the Page_Load event. Override the OnPreRender event
and perform the calculations and manipulations there. Then you'll be able to
pickup the values in the page.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
D

Darrel

Darrel,
Make sure that any calculations or things that are going on in the
control are not done in the Page_Load event. Override the OnPreRender
event and perform the calculations and manipulations there. Then you'll be
able to pickup the values in the page.

Hmm...I wrote a Page_PreRender() sub, but couldn't get that to work.

However, moving the function from the page_load to page_init solved the
problem. Is that an acceptable solution?

-Darrel
 

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,767
Messages
2,569,573
Members
45,046
Latest member
Gavizuho

Latest Threads

Top