Any other ideas for setting variables in a user control

Discussion in 'ASP .Net' started by David Hearn, May 4, 2006.

  1. David Hearn

    David Hearn Guest

    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!
     
    David Hearn, May 4, 2006
    #1
    1. Advertising

  2. David Hearn

    Patrice Guest

    Choose the best approach (IMO the first one) and tell us what is the exact
    message raised...
    --

    "David Hearn" <> a écrit dans le message de news:
    e$q39$...
    >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!
    >
     
    Patrice, May 4, 2006
    #2
    1. Advertising

  3. David Hearn

    David Hearn Guest

    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" <> wrote in message
    news:...
    > Choose the best approach (IMO the first one) and tell us what is the exact
    > message raised...
    > --
    >
    > "David Hearn" <> a écrit dans le message de news:
    > e$q39$...
    >>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!
    >>

    >
    >
     
    David Hearn, May 4, 2006
    #3
  4. David Hearn

    Patrice Guest

    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" <> a écrit dans le message de news:
    ...
    > 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" <> wrote in message
    > news:...
    >> Choose the best approach (IMO the first one) and tell us what is the
    >> exact message raised...
    >> --
    >>
    >> "David Hearn" <> a écrit dans le message de news:
    >> e$q39$...
    >>>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!
    >>>

    >>
    >>

    >
    >
     
    Patrice, May 4, 2006
    #4
  5. David Hearn

    David Hearn Guest

    Patrice,

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


    "Patrice" <> wrote in message
    news:...
    > 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" <> a écrit dans le message de news:
    > ...
    >> 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" <> wrote in message
    >> news:...
    >>> Choose the best approach (IMO the first one) and tell us what is the
    >>> exact message raised...
    >>> --
    >>>
    >>> "David Hearn" <> a écrit dans le message de news:
    >>> e$q39$...
    >>>>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!
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    David Hearn, May 4, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Hearn
    Replies:
    2
    Views:
    758
    Lau Lei Cheong
    Jun 24, 2004
  2. Chris Zopers

    Access user control from other user control

    Chris Zopers, Feb 20, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    591
    Nanda Lella[MSFT]
    Apr 27, 2009
  3. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    583
    Jonathan Wood
    Feb 2, 2010
  4. Nikolay Anestev

    creating custom web control .. any ideas ?

    Nikolay Anestev, Feb 22, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    151
    Nikolay Anestev
    Feb 22, 2005
  5. Sue
    Replies:
    6
    Views:
    145
    Phillip Williams
    Dec 12, 2005
Loading...

Share This Page