How to hide a control in a master page?

Posted on 2010-09-04
Last Modified: 2012-08-13

I have a master page which has a menu and a control (DropDownList) that must be hidden according to the section in which the user navigates.

How to do that ?

Thanks in advance.
Question by:dimensionav
  • 4
  • 2
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 33603888
Use display: none; in CSS to hide any element in HTML document.

Author Comment

ID: 33603897
but in ASP how could I know in which page is the user navigating, in order to decide when to hide the control?
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 33603916
Are you using AJAX?
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.


Author Comment

ID: 33603924
not Jet, but if you show me how I wouldn´t mind to use it

Accepted Solution

teleportator earned 500 total points
ID: 33609027
On the page you want to hide your user control you can do the following:
Control myControl = his.Master.FindControl("ControlIDYouWantToHide");

myControl.Visible = false;

Open in new window


Author Comment

ID: 33620385
I have to perform some changes to your code, first of all I have changed it to VB and added it inside of INIT event, just like this:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim mddlCategory As DropDownList = Me.Master.FindControl("ddlCategory")
        mddlCategoria.Visible = False
    End Sub

Open in new window


Author Closing Comment

ID: 33620408
Te code was a little different (C#) but with some adjustments it worked very well.

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now