如何在主页面上使注销按钮不可见。在登录页面中,显示注销按钮
是没有意义的答案 0 :(得分:0)
您可以检查母版页中的User.Identity.Name
是否为空字符串
答案 1 :(得分:0)
您也可以使用LoginView control来实现此目的:
根据以下内容显示给定用户的相应内容模板 用户的身份验证状态和角色成员身份。
<asp:LoginView ID="lv" runat="server">
<AnonymousTemplate>
<!-- child controls -->
</AnonymousTemplate>
<LoggedInTemplate>
<!-- child controls -->
</LoggedInTemplate>
</asp:LoginView>
因此,您可以将注销按钮移动到 LoggedInTemplate 容器中。
答案 2 :(得分:0)
当登录页面上userId上的会话为空时,只需使按钮可见性为false。
在LoginPage的page_load上
protected void page_load(argument e) { if(session[userId]==null) { logoutbttn.visible=false; } }