显示LoginName控件全名而不是用户名 [英] Display Full Name Instead of Username in LoginName Control

查看:349
本文介绍了显示LoginName控件全名而不是用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

LoginName控件显示用户名。我想显示全名的用户登录,而不是用户名。下面是我的code。我似乎无法身后访问code LoginName控件。我想知道如果不是因为控制在

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页面:

<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>

请张贴背后例子code在C#如果可能的话...

Please post code behind examples in C# if possible...

推荐答案

我能找出一条捷径:

LoginName loginName = HeadLoginView.FindControl("HeadLoginName") as LoginName;

        if (loginName != null && session != null)
        {
            loginName.FormatString = "Full Name";
        }

这找到一个LoginView内LoginName控件,然后劫持通过设置formatString中的价值。我希望有这样做的更优雅的方式。如果有谁知道,请把我的方式。

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.

这篇关于显示LoginName控件全名而不是用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆