Set label value in LoginView

Posted on 2009-04-22
Last Modified: 2013-11-07

I have a loginview control with a LoggedInTemplate. This template has a few lablels controls, but when I try to use them like - me.lblLastloggedIn I get an error.

How do I target these controls. Attached is a section of my login view.

<asp:LoginView ID="LoginView" runat="server">



            <div class="blue">


                        <legend><asp:Image ID="imgStats" runat="server" ImageUrl="~/App_Themes/Expert/Images/Reports_32.png"  Width="32px" Height="32px" CssClass="pageicons"/>Expert Stats</legend>


                        <p>Logged in as:<asp:LoginName ID="LoginName" runat="server" /></p>

                        <p>Available Licences:<asp:Label id="lblLicenses" runat="server"></asp:Label></p>

                        <p>Last Logged in:<asp:Label id="lblLastLoggedIn" runat="server"></asp:Label></p>





Open in new window

Question by:Andy Green
    LVL 12

    Accepted Solution

    you can get the reference to a control in a template by using FindControl

    Label lbl = (Label)this.LoginView1.FindControl("lblLastLoggedIn");
    LVL 3

    Author Closing Comment

    by:Andy Green
    Thank you

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    728 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

    17 Experts available now in Live!

    Get 1:1 Help Now