Exposing properties of a user control to the web forms page

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

http://msdn.microsoft.com/library/d...l/vbwlkwalkthroughcreatingwebusercontrols.asp

Following the above example I created a usercontrol and added it to another
web form MyPage.aspx. Then I added code to declare the user control as
instructed in the above article:

' Visual Basic menu as a user control
Public Class MyPage
Inherits System.Web.UI.Page
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected Menu1 As menu

But if I try to make a call to menu1 (menu1.itemname = "test") it screams at
me that the object has not been created and is still "nothing". When/how
does the user control object (menu1) get created. What step am I missing
here.

Thanks in advance,

Jason
 
Are you putting your code in the OnLoad event handler? You can't access this
control until it has completed loading.
 
Back
Top