Login.VisibleWhenLoggedIn 属性

定义

获取或设置一个值,该值指示在验证用户身份后是否显示 Login 控件。Gets or sets a value indicating whether to show the Login control after the user is authenticated.

public:
 virtual property bool VisibleWhenLoggedIn { bool get(); void set(bool value); };
[System.Web.UI.Themeable(false)]
public virtual bool VisibleWhenLoggedIn { get; set; }
member this.VisibleWhenLoggedIn : bool with get, set
Public Overridable Property VisibleWhenLoggedIn As Boolean

属性值

如果在验证用户身份后隐藏 false 控件,则为 Login;否则为 truefalse if the Login control should be hidden when the user is authenticated; otherwise, true. 默认为 trueThe default is true.

属性

示例

下面的代码示例将 VisibleWhenLoggedIn 属性设置为 true 以指定 Login 控件不隐藏并且始终显示在页上,不管用户是否已经过身份验证。The following code example sets the VisibleWhenLoggedIn property to true to specify that the Login control is not hidden and is always displayed on the page, regardless of whether the user has been authenticated.

<%@ Page Language="VB" AutoEventWireup="False"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Login Sample</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:Login id="Login1" runat="server" 
            VisibleWhenLoggedIn="true">
        </asp:Login>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="False"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Login Sample</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:Login id="Login1" runat="server" 
            VisibleWhenLoggedIn="true">
        </asp:Login>
</form>
</body>
</html>

注解

VisibleWhenLoggedIn 属性指定是否向经过身份验证的用户显示 Login 控件。The VisibleWhenLoggedIn property specifies whether the Login control is displayed to authenticated users. 如果 false属性,则当经过身份验证的用户访问站点时,Login 控件不会出现在该页上。When the property is false, the Login control does not appear on the page when an authenticated user accesses the site. 这适用于在用户身份验证后用作登录页和信息页以隐藏 Login 控件的网页。This is used on Web pages that are used both as login pages and as information pages to hide the Login control after the user has been authenticated.

VisibleWhenLoggedIn 属性对出现在 web.config 中或应用程序配置文件中定义的默认登录页上的 Login 控件不起作用。The VisibleWhenLoggedIn property has no effect on a Login control that appears on the default login page defined in Web.config or in the application's configuration file.

无法通过主题或样式表主题设置此属性。This property cannot be set by themes or style sheet themes. 有关详细信息,请参阅 ThemeableAttributeASP.NET 主题和外观For more information, see ThemeableAttribute and ASP.NET Themes and Skins.

适用于

另请参阅