I have a default page called default.aspx and a web user control called test.ascx in a folder called controls. Now, if I drag the control on to default.aspx from visual studio and set the properties, it works fine. The problem comes when I try to add the control to default.aspx from the codebehind default.aspx.vb
VB Code:
'test.ascx.vb Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Label1.Text = Me.ID End Subwhen I run this, I get a "NullReferenceException" error on the line Label1.Text = Me.ID in the test.ascx.vb file. It is telling me that the Object Label1 doesn't exist. I am really confussed with 2.0 because you don't dimesion the controls in the codebehind.VB Code:
'default.aspx.vb Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim MyControl as New Controls_Test MyControl.ID = "SomeID" End Sub




I drink to make other people more interesting!
Reply With Quote