Passing values to user controls - naughty problem

Discussion in 'ASP .Net Web Controls' started by Dave E, Jul 2, 2006.

  1. Dave E

    Dave E Guest

    Hi all,

    right now I feel pretty dumb - even dumber than I look. I have read endless
    web articles on this, including the excellent site by Steve Orr
    (http://steveorr.net/faq/PassDataToUserControl.aspx) on this very issue,
    sadly to no avail in my case.

    I've followed the examples and can only get the glorious "Object reference
    not set to an instance of an object" error when I attempt to set the public
    property on the control. Intellisense picks up the [IsCheckout] property on
    the control and so at least that part is OK. I tried calling a public sub
    on the control from a button press on the parent page but same error.

    Essentially I just want to pass a simple boolean to the control to give it
    context but this one has cost me much sleep - must be a *very* simple answer
    I'm guessing.

    My code is as follows (please don't laugh...):

    [------- My control (i_cart_list1) --]

    Private blnIsCheckout As Boolean

    Public Property IsCheckout() As Boolean
    Get
    Return blnIsCheckout
    End Get

    Set(ByVal Value As Boolean)
    blnIsCheckout = Value
    End Set
    End Property


    [------- Parent page --]

    Protected WithEvents Checkout As i_cart_list1

    Private Sub Page_Load(blah blah here...)
    Checkout.IsCheckout = True '<== Error happens here
    End Sub

    -----------------------------

    Many thanks in advance for any help on this nasty.

    Cheers,
    David E (Sydney)
     
    Dave E, Jul 2, 2006
    #1
    1. Advertising

  2. Dave, in your .aspx page that contains your user control, make sure that the
    id of the user control is the same id you used in the codebehind for that
    page. From your example it seems as though the id is Checkout. Are you sure,
    can you verify this ? I think this is the problem as to why your control is
    returning an object reference error.

    Regards,
    Alessandro Zifiglio
    "Dave E" <> ha scritto nel messaggio
    news:44a7d387$0$17549$...
    > Hi all,
    >
    > right now I feel pretty dumb - even dumber than I look. I have read
    > endless web articles on this, including the excellent site by Steve Orr
    > (http://steveorr.net/faq/PassDataToUserControl.aspx) on this very issue,
    > sadly to no avail in my case.
    >
    > I've followed the examples and can only get the glorious "Object reference
    > not set to an instance of an object" error when I attempt to set the
    > public property on the control. Intellisense picks up the [IsCheckout]
    > property on the control and so at least that part is OK. I tried calling
    > a public sub on the control from a button press on the parent page but
    > same error.
    >
    > Essentially I just want to pass a simple boolean to the control to give it
    > context but this one has cost me much sleep - must be a *very* simple
    > answer I'm guessing.
    >
    > My code is as follows (please don't laugh...):
    >
    > [------- My control (i_cart_list1) --]
    >
    > Private blnIsCheckout As Boolean
    >
    > Public Property IsCheckout() As Boolean
    > Get
    > Return blnIsCheckout
    > End Get
    >
    > Set(ByVal Value As Boolean)
    > blnIsCheckout = Value
    > End Set
    > End Property
    >
    >
    > [------- Parent page --]
    >
    > Protected WithEvents Checkout As i_cart_list1
    >
    > Private Sub Page_Load(blah blah here...)
    > Checkout.IsCheckout = True '<== Error happens here
    > End Sub
    >
    > -----------------------------
    >
    > Many thanks in advance for any help on this nasty.
    >
    > Cheers,
    > David E (Sydney)
    >
     
    Alessandro Zifiglio, Jul 2, 2006
    #2
    1. Advertising

  3. Dave E

    Dave E Guest

    "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in
    message news:%...
    > Dave, in your .aspx page that contains your user control, make sure that
    > the id of the user control is the same id you used in the codebehind for
    > that page. From your example it seems as though the id is Checkout. Are
    > you sure, can you verify this ? I think this is the problem as to why your
    > control is returning an object reference error.
    >
    > Regards,
    > Alessandro Zifiglio


    Hi Alessandro,

    well, my sincere thanks to you - you've saved me from tearing the final few
    strands of hair out! I was right on one point though... it was a
    ridiculously easy solution, but clearly way beyond me!

    Many thanks and I appreciate your time.

    Cheers from Sydney,
    Dave E
     
    Dave E, Jul 3, 2006
    #3
  4. Dave, you are welcome :)
    have a good day,
    Alessandro Zifiglio
    "Dave E" <> ha scritto nel messaggio
    news:44a86745$0$17541$...
    > "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in
    > message news:%...
    >> Dave, in your .aspx page that contains your user control, make sure that
    >> the id of the user control is the same id you used in the codebehind for
    >> that page. From your example it seems as though the id is Checkout. Are
    >> you sure, can you verify this ? I think this is the problem as to why
    >> your control is returning an object reference error.
    >>
    >> Regards,
    >> Alessandro Zifiglio

    >
    > Hi Alessandro,
    >
    > well, my sincere thanks to you - you've saved me from tearing the final
    > few strands of hair out! I was right on one point though... it was a
    > ridiculously easy solution, but clearly way beyond me!
    >
    > Many thanks and I appreciate your time.
    >
    > Cheers from Sydney,
    > Dave E
    >
     
    Alessandro Zifiglio, Jul 3, 2006
    #4
    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. Replies:
    0
    Views:
    412
  2. Faizan Ahmed
    Replies:
    1
    Views:
    308
    John Saunders
    Jan 4, 2005
  3. Faizan Ahmed
    Replies:
    1
    Views:
    388
    John Saunders
    Jan 4, 2005
  4. Peter K

    Passing values between user controls

    Peter K, Jan 13, 2010, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    1,167
    Nathan Sokalski
    Feb 18, 2010
  5. Phlip
    Replies:
    8
    Views:
    197
    David A. Black
    Aug 22, 2004
Loading...

Share This Page