I have a simple, single-page in ASP.NET (C#). I wanted to add login control, so I just added LoginView as follows:
<form id="form1" runat="server">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:Login ID="Login1" runat="server">
</asp:Login>
</AnonymousTemplate>
<LoggedInTemplate>
... here I put all the page elements (buttons, grid views, etc.)
</LoggedInTemplate>
</asp:LoginView>
</form>
When I run my project I get compilation errors in my code-behing file:
The name xxxx does not exist in the current context
What am I doing wrong? I'm new in ASP.NET, so probably it is some stupid mistake I make.
I have found this as the solution for my problem. I can use this, to get my objects.
Label Label1 = (Label)LoginView1.FindControl("Label1");
I don't know if it is the only solution. Maybe someone has better.