Hide menu on login screen C#

Asked

Viewed 169 times

0

I have a little problem, I need to hide a menu on the login screen when it is loaded. I used a solution that works locally, but on the server does not happen, follow below:

//MENU QUE FICA NA MASTER PAGE
 <asp:Panel ID="Panel1" runat="server">
                <asp:LoginView runat="server" ViewStateMode="Disabled">
                    <AnonymousTemplate>
                      //CONTEUDO DO MENU
                    </AnonymousTemplate>
                 </asp:LoginView>
 </asp:Panel>

//ISSO ESTÁ NO PAGE_LOAD DA TELA DE LOGIN
Panel ocultaMenu = (Panel)Master.FindControl("Panel1");
ocultaMenu.Visible = false;
  • I wonder, in which file you put this configuration there?

2 answers

0

I tested your code here and it works normally, but as it is not working on the server it costs nothing to check other possibilities.

You can create a method in Master.Cs that gets true or false, in this method you show or hide the component.

public partial class MyMaster : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void EsconderExibirPanel(bool exibe)
    {
        Panel1.Visible = exibe;
    }
}

And where you want to hide the component can invoke this method.

((MyMaster)Page.Master).EsconderExibirPanel(false);
  • So I came to make this attempt as well and still the server was not working. Finally I discovered the problem, I was only going up the pieces of code I changed, when I sent the whole project worked. Thanks for the strength man!

  • Quiet, the Important who worked!

0

You can try to change the property of the element (Design), and according to login make change in the code. In property go to Behavior, find the Enabled option and put false. in the code where you want to load puts Panel1.Enabled = true;

  • <Asp:Panel ID="Panel1" runat="server" Enabled="False">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.