开发者

how to display a logout button once the users lpgs in

开发者 https://www.devze.com 2023-03-23 19:52 出处:网络
i have a logout [link button] in master page and i want to show it once the user logs in. I did this way

i have a logout [link button] in master page and i want to show it once the user logs in. I did this way

pro开发者_如何转开发tected void LoginAction_Click(object sender, EventArgse)
    {

    LinkButton btnSignout = (LinkButton)Master.FindControl("btnLogout");
        if (btnSignout != null)
        {
            btnSignout.visible=True;
        }

        Response.Redirect("home.aspx");
    }


just add LoginStatus in LoggedInTemplate control

 <LoggedInTemplate>
    <asp:LoginStatus ID="LoginStatus1" runat="server" OnLoggedOut="LoginStatus1_LoggedOut"                                             
    LogoutText="Sign Out" CssClass="linkLoginControls" />
 </LoggedInTemplate>

LoggedInTemplate will be visible when the user logged in


I'm not sure what you are asking for but it sounds like you are wondering how to reference content in the master page?

http://msdn.microsoft.com/en-us/library/xxwa0ff0.aspx


If you can't use a loginstatus control then you can check on page load if the user is authenticated, and if so have your logout button/hyperlink there set to visible.

0

精彩评论

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

关注公众号