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
    ( 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
    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.

    David E (Sydney)
    Dave E, Jul 2, 2006
    1. Advertisements

  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.

    Alessandro Zifiglio
    Alessandro Zifiglio, Jul 2, 2006
    1. Advertisements

  3. Dave E

    Dave E Guest

    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
  4. Dave, you are welcome :)
    have a good day,
    Alessandro Zifiglio
    Alessandro Zifiglio, Jul 3, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.