The LoginName control displays the Username. I would like to display the Full Name of the user logged in rather than the Username. Below is my code. I cannot seem to access the LoginName control in code behind. I am wondering if it because the control is in .
ASPX Page:
<asp:loginview id="HeadLoginView" runat="server" enableviewstate="false">
<AnonymousTemplate>
[ <a id="HeadLoginStatus" runat="server" href="login">Log In</a> ]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold">
<asp:LoginName ID="HeadLoginName" runat="server" />
</span>! [
<asp:LoginStatus ID="HeadLoginStatus" runat="server"
LogoutAction="Redirect" LogoutPageUrl="~/home"
LogoutText="Log Out" />
]
</LoggedInTemplate>
</asp:loginview>
Please post code behind examples in C# if possible...
I was able to figure out a short cut:
LoginName loginName = HeadLoginView.FindControl("HeadLoginName") as LoginName;
if (loginName != null && session != null)
{
loginName.FormatString = "Full Name";
}
This finds the LoginName control within the LoginView, then hijacks the value by setting FormatString. I wish there was a more elegant way of doing this. If anyone knows, please send it my way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With