By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,920 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,920 IT Pros & Developers. It's quick & easy.

Any other ideas for setting variables in a user control

P: n/a
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!
May 4 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Choose the best approach (IMO the first one) and tell us what is the exact
message raised...
--

"David Hearn" <Da*********@shawinc.com> a écrit dans le message de news:
e$**************@TK2MSFTNGP05.phx.gbl...
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!

May 4 '06 #2

P: n/a
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!

"Patrice" <sc****@chez.com> wrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
Choose the best approach (IMO the first one) and tell us what is the exact
message raised...
--

"David Hearn" <Da*********@shawinc.com> a écrit dans le message de news:
e$**************@TK2MSFTNGP05.phx.gbl...
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!


May 4 '06 #3

P: n/a
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

"David Hearn" <Da*********@shawinc.com> a écrit dans le message de news:
et**************@TK2MSFTNGP03.phx.gbl...
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!

"Patrice" <sc****@chez.com> wrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
Choose the best approach (IMO the first one) and tell us what is the
exact message raised...
--

"David Hearn" <Da*********@shawinc.com> a écrit dans le message de news:
e$**************@TK2MSFTNGP05.phx.gbl...
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!



May 4 '06 #4

P: n/a
Patrice,

You were right. I just treated it as another control and it worked. Thank
you for your help!
"Patrice" <sc****@chez.com> wrote in message
news:OV**************@TK2MSFTNGP04.phx.gbl...
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

"David Hearn" <Da*********@shawinc.com> a écrit dans le message de news:
et**************@TK2MSFTNGP03.phx.gbl...
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!

"Patrice" <sc****@chez.com> wrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
Choose the best approach (IMO the first one) and tell us what is the
exact message raised...
--

"David Hearn" <Da*********@shawinc.com> a écrit dans le message de news:
e$**************@TK2MSFTNGP05.phx.gbl...
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!



May 4 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.