共用方式為


LoginStatus Web Server Control Declarative Syntax 

Detects the user's authentication state and toggles the state of a link to display whether the users can log on to or log off from a Web site.

<asp:LoginStatus
    AccessKey="string"
    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
                 Inset|Outset"
    BorderWidth="size"
    CssClass="string"
    Enabled="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    Font-Bold="True|False"
    Font-Italic="True|False"
    Font-Names="string"
    Font-Overline="True|False"
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
               Large|X-Large|XX-Large"
        Font-Strikeout="True|False"
    Font-Underline="True|False"
    ForeColor="color name|#dddddd"
    Height="size"
    ID="string"
    LoginImageUrl="uri"
    LoginText="string"
    LogoutAction="Refresh|Redirect|RedirectToLoginPage"
    LogoutImageUrl="uri"
    LogoutPageUrl="uri"
    LogoutText="string"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnLoggedOut="LoggedOut event handler"
    OnLoggingOut="LoggingOut event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    runat="server"
    SkinID="string"
    Style="string"
    TabIndex="integer"
    ToolTip="string"
    Visible="True|False"
    Width="size"
/>

Remarks

The LoginStatus control has two states:

  • Logged on to the Web site.

  • Logged off from the Web site.

The state is determined by the IsAuthenticated property of the Request property.

For more information on using the LoginStatus control and other login controls, see Login ASP.NET Controls.

Example

This following code example shows how to use the LoginStatus control to create a link for a user to log on to or log off from a Web site.

<asp:LoginStatus id="LoginStatus1" loginText="Log In"
             logoutAction="Refresh" logoutText="Log Out"
             runat="server" /> 
<asp:LoginStatus id="LoginStatus1" loginText="Log In"
             logoutAction="Refresh"  logoutText="Log Out"
             runat="server" /> 

See Also

Reference

LoginStatus

Other Resources

Login ASP.NET Controls