Set label value in LoginView

Posted on 2009-04-22
Medium Priority
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

wht1986 earned 2000 total points
ID: 24204049
you can get the reference to a control in a template by using FindControl

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

Author Closing Comment

by:Andy Green
ID: 31573239
Thank you

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 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