Trying to hide a user control

  • Thread starter Thread starter Geoff Pennington
  • Start date Start date
G

Geoff Pennington

We use a user control, SCMMenu.ascx, as our menu at the top of our web
pages. Under some circumstances we need to hide the menu.

At the top of the (.aspx) page we register the control with:
<%@ Register TagPrefix="eSCM" TagName="ctrlSCMMenu"
Src="/eSoftware/Common/SCMMenu.ascx" %>

At the place in the HTML where the control appears we have:
<escm:ctrlscmmenu id="ctrlSCMMenu" name="ctrlSCMMenu" runat="server"
Visible="True"></escm:ctrlscmmenu>

This is pretty standard stuff, and it works, What I want to do is place code
in the code-behind file that can hide the user control. I thought I could do
it with
ctrlSCMMenu.visible = false

but I get a syntax error claiming that the name ctrlSCMMenu has not been
declared. Any ideas?

Much obliged.
 
You should manually declare usercontrols. VS.NET does not create any
declaration automatically like when you put a TextBox on the page. Be
careful about using exactly the same name.

Good Luck.
 
OK, thanks, got it. I added
Public ctrlSCMMenu As New UserControl
as a class variable in my code-behind and that took care of it.

Geoff.
 
Back
Top