how to display a logout button once the users lpgs in
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.
精彩评论