I have a user control with a label and a method. The webform should call
the method on the user control and populate the label. I am getting
object not set errors as soon as I try to access the label on the user
control.
A small sample of code would be greatly appreciated.
Nice little "secret" solution to this I believe.
You need to explicitly declare the object variable for your user control,
unlike when you add a normal control and VS does it for you:
Protected WithEvents Control ID As UsercontrolType (where Control ID is the
id of the control after you dragged it onto your web form, and
usercontroltype is the class name)
Hope this helps. Not sure if the WithEvents is required or recommend, might
depend on your implementation
> I have a user control with a label and a method. The webform should call
> the method on the user control and populate the label. I am getting
> object not set errors as soon as I try to access the label on the user
> control.
>
> A small sample of code would be greatly appreciated.
Victor Garcia Aprea [MVP] - 23 Oct 2003 21:43 GMT
Small note: keep in mind that for the parser to do its magic, you need to
name your member variable *exactly* after the value of the ID attribute
given in your usercontrol tag.

Signature
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
> Nice little "secret" solution to this I believe.
>
[quoted text clipped - 14 lines]
> >
> > A small sample of code would be greatly appreciated.