Home All Groups Group Topic Archive Search About

Passing values to user controls - naughty problem

Author
2 Jul 2006 2:09 PM
Dave E
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)

Author
2 Jul 2006 2:26 PM
Alessandro Zifiglio
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
Show quoteHide quote
"Dave E" <dave@a.b.c> ha scritto nel messaggio
news:44a7d387$0$17549$61c65585@un-2park-reader-01.sydney.pipenetworks.com.au...
> 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)
>
Author
3 Jul 2006 12:39 AM
Dave E
"Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in
message news:%23hYe7NenGHA.4352@TK2MSFTNGP02.phx.gbl...
> 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
Author
3 Jul 2006 6:23 AM
Alessandro Zifiglio
Dave, you are welcome :-)
have a good day,
Alessandro Zifiglio
Show quoteHide quote
"Dave E" <dave@a.b.c> ha scritto nel messaggio
news:44a86745$0$17541$61c65585@un-2park-reader-01.sydney.pipenetworks.com.au...
> "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> wrote in
> message news:%23hYe7NenGHA.4352@TK2MSFTNGP02.phx.gbl...
>> 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
>