Any other ideas for setting variables in a user control

  • Thread starter Thread starter David Hearn
  • Start date Start date
D

David Hearn

I need to pass some variables to a user control so that some functions that
are in it can use them. I am trying to set a public property that I have in
it but it isn't working for some reason and I really need to get this
working. Any ideas? I have tried calling the functions directly from the
parent page's page load event, but that doesn't work because the controls
aren't rendered yet and I keep getting Object not set to reference errors.

Thanks in advance!
 
Choose the best approach (IMO the first one) and tell us what is the exact
message raised...
 
Patrice,

I set the property and can see it come in just fine as it is being set, but
by the time I try to use it in calling a function, the variable is set to
nothing again. It's getting lost or something is resetting it. See my
previous post just below this one about problem accessing proerty in User
control.

Thanks!
 
Ok, as reported by Marina looks like you create a new instance, set the
property and set it to nothing again (basically it has no effect).

If you dropped the user control on your page you have a variable that is
automatically created there for you and that allows to handle this control
(check its name in the design view).
You can then use this variable to set the needed property.

This is very similar to using any other control...
 
Patrice,

You were right. I just treated it as another control and it worked. Thank
you for your help!
 

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