Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / October 2003

Tip: Looking for answers? Try searching our database.

User control newbie question - pls help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul Barnett - 01 Oct 2003 22:28 GMT
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.
Travis Bolton - 23 Oct 2003 17:02 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.