I have a panel in aspx, but it gives error in the code behind (Web Form)

-1

I have a project in aspx to maintain and I have this in the aspx page

<asp:Panel ID="painelTeste" runat="server">

and in the code behind gives error

  

The panelTest name does not exist in the current context.

What should I do?

EDit1

My context in the code behind.

if (DateTime.Now < dataFaturamento)
{
    painelTeste .Visible = false;
}
else
{
    painelTeste .Visible = true;
}
    
asked by anonymous 28.12.2018 / 15:49

1 answer

5

This panel was probably created when the project was running, so the reference to it was not generated in the NomeDaSuaPagina.aspx.designer.cs file.

It needs to be a similar reference in the page designer:

protected global::System.Web.UI.WebControls.Panel painelTeste;

Try to add this reference manually, if it does not work delete the control, save the project, restart Visual Studio, and then type the control again that the designer will be complemented correctly.

    
28.12.2018 / 16:45