can't seem to hide user control with code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi I am trying to conditionally hide a user control on a form in the code.
There is a visible element in the properties box of the user control but in
the .vb file (in the code) the object does not seem available. Using me. the
intellsince does not show the user control name, so can not seem to get to
its properties in code.
Thanks.
Paul G
Software engineer.
 
Hi thanks for the response. It is a control that I created.
I tried the following but get a runtime error (Object reference is not set
to an instance of an object) when using
Imports projectname.usercontrolname '
Me.usercontrolname.Visible = False ' runtime error occures here.
I also set up the code below like what you had suggested which seems to run
ok but not sure if it is itterating through all of the controls on the form.
For Each ctrl As Control In Me.Controls
ctrl.Visible = True
Next
 
I think asp.net for efficiency reasons creates 5 child controls, some
of which are null. So you need to insert into the foreach loop:
if(ctrl != null) { ctrl.Visible = True }

or however you write that in VB.
 
ok thanks for the information, think it would be
if ctrl <> NULL then
ctrl.visible = True
end if
 
Back
Top