0
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
    <AnonymousTemplate>
        [ <a href="~/Account/Login.aspx" ID="HeadLoginStatus" runat="server">Log In</a> ]
    </AnonymousTemplate>
    <LoggedInTemplate>
        Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" />,
            You're <asp:Label ID="AgeLabel" runat="server" Text="Label"> </asp:Label></span>!
        [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
    </LoggedInTemplate>
</asp:LoginView>

こんなことしたい

AgeLabel.Text = Profile.GetPropertyValue("Age").ToString();

これどうやってするの?テンプレート内のAgeLabeliなので、参照できないように見えます

4

2 に答える 2

1

フォローしてみましたか?

<asp:Label ID="AgeLabel" runat="server" Text='<%# Profile.GetPropertyValue("Age").ToString() %>' />

それ以外の場合は、FindControlを使用してCodebehindからラベルにアクセスできます。

Dim AgeLabel As Label = DirectCast(HeadLoginView.FindControl("AgeLabel"), Label)
于 2011-04-10T20:13:40.420 に答える
0

または、要素を分解することもできます。ログイン制御用の「テンプレートに変換」オプションがあります。すべての要素を個別の要素として使用しますが、ログインコントロールの機能は保持されます

于 2011-04-11T06:06:09.530 に答える