Results 1 to 2 of 2

Thread: [RESOLVED] asp.net 2.0 user control problem

Threaded View

  1. #1

    Thread Starter
    Frenzied Member blindlizard's Avatar
    Join Date
    Feb 2001
    Location
    Austin, TX - United States of America
    Posts
    1,141

    Resolved [RESOLVED] asp.net 2.0 user control problem

    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:
    1. 'test.ascx.vb
    2. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    3.         Label1.Text = Me.ID
    4. End Sub
    VB Code:
    1. 'default.aspx.vb
    2. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    3.    Dim MyControl as New Controls_Test
    4.    MyControl.ID = "SomeID"
    5. End Sub
    when 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.
    Last edited by blindlizard; Nov 14th, 2005 at 03:36 PM.
    I drink to make other people more interesting!
    [vbcode]On Error GoTo Bar[/vbcode]
    http://www.monsterlizard.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width