Trying to hide a user control

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.
 
D

dincerozturan

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.
 
G

Geoff Pennington

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top