本文介绍了母版页控制访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从内容页面访问母版页变量或标签.

我想要用户登录时,其名称和注销按钮出现在MasterPage上.

I want to access master page variable or label, from a content page.

I want when user logged in, his name and logout button appears on the MasterPage.

推荐答案

protected void Page_Load(object sender, EventArgs e)
{
   Label lbl = (Label)Master.FindControl("ContentPlaceHolder1").FindControl("Label1");
   string test = lbl.Text;
}





<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="Label1" runat="server" Text="yyyyyyyy"></asp:Label>
</asp:Content>



对于Access变量:您可以设置专有属性.
最好的问候
M.Mitwalli



For Access variable : you can make proprieties .
Best Regards
M.Mitwalli


<div class="loginDisplay">
    <asp:LoginView ID="LoginView1" 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" />
            </span>!
            [ <asp:LoginStatus ID="HeadLoginStatus" runat="server"
                 LogoutAction="Redirect" LogoutText="Log Out"
                LogoutPageUrl="~/" /> ]
        </LoggedInTemplate>
    </asp:LoginView>
</div>


希望对您有帮助


Hope it help



这篇关于母版页控制访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 08:02
查看更多