Passing values to user controls - naughty problem

D

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)
 
A

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
 
D

Dave E

Alessandro Zifiglio said:
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
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top