Solved

How to hide a control in a master page?

Posted on 2010-09-04
7
474 Views
Last Modified: 2012-08-13
HI

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.
0
Comment
Question by:dimensionav
  • 4
  • 2
7 Comments
 
LVL 12

Expert Comment

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

Author Comment

by:dimensionav
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?
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 33603916
Are you using AJAX?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

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

Accepted Solution

by:
teleportator earned 500 total points
ID: 33609027
Hello!
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

0
 

Author Comment

by:dimensionav
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

0
 

Author Closing Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

856 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