user control

  • Thread starter Thread starter RCIC
  • Start date Start date
R

RCIC

If I add a user control to a webform, it seems like I
should be able to make it visable or invisable. My code
doesn't seem to work. To test this I made a control
called myControl and dragged to on to my web form. I then
added this to the code behind and ran it.

Public test As myControl

Private Sub Page_Load(ByVal sender .....
test.Visible = False
End Sub

The error I get is: Object reference not set to an
instance of an object. Any idea what my problem is?
 
Doesn't look to me as if you created an instance of the user control to
hide.

-j
 
RCIC,

Jesse is correct. You are attempting to add a control to your page
dynamically.

There are two things your code is missing.

One is to create a NEWcontrol:

Public test As New MyControl

The second is to actually add the control to the page (or a container on the
page like a placeholder).

Page.Controls.Add(MyControl)


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
Back
Top