开发者

Change the text of a Label inside a LoginView

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

I want to do something like

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

How can I do开发者_Go百科 this? AgeLabel i inside a template so it looks like I can't refference it in


Have you tried following?

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

Otherwise you could access the Label from Codebehind with FindControl:

Dim AgeLabel As Label = DirectCast(HeadLoginView.FindControl("AgeLabel"), Label)


Or you can break elements apart, there is an option "Convert to template" for login control. You will have all elements as separate elements but the functionality of Login control is preserved

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜