Share via


Login.Password Vlastnost

Definice

Získá heslo zadané uživatelem.

public:
 virtual property System::String ^ Password { System::String ^ get(); };
[System.ComponentModel.Browsable(false)]
public virtual string Password { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Password : string
Public Overridable ReadOnly Property Password As String

Hodnota vlastnosti

Heslo zadané uživatelem. Výchozí formát je null.

Atributy

Příklady

Následující příklad kódu předá Password vlastnost vlastní metodě ověřování.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
private bool SiteSpecificAuthenticationMethod(string UserName, string Password)
{
    // Insert code that implements a site-specific custom 
    // authentication method here.
    //
    // This example implementation always returns false.
    return false;
}

private void OnAuthenticate(object sender, AuthenticateEventArgs e)
{
    bool Authenticated = false;
    Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password);

    e.Authenticated = Authenticated;
}

</script>

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

<script runat="server">
Function SiteSpecificAuthenticationMethod(ByVal UserName As String, ByVal Password As String) As Boolean
    ' Insert code that implements a site-specific custom 
    ' authentication method here.
    '
    ' This example implementation always returns false.
    Return False
End Function

Sub OnAuthenticate(ByVal sender As Object, ByVal e As AuthenticateEventArgs)
    Dim Authenticated As Boolean
    Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password)

    e.Authenticated = Authenticated
End Sub


</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server"
                OnAuthenticate="OnAuthenticate">
            </asp:Login>

        </form>
    </body>
</html>

Poznámky

Vlastnost Password obsahuje heslo zadané uživatelem. Heslo je ve formátu prostého textu. Další informace najdete v tématu Základní postupy zabezpečení pro webové aplikace.

Poznámka

Pokud s vlastnostmi UserName nebo Password pracujete programově, je důležité to udělat ve správný čas během životního cyklu stránky. Hodnoty UserName a Password nejsou k dispozici během Page_Load fáze, ale jsou v průběhu Pre_Render fáze.

Login Vlastnosti ovládacích prvků reprezentované textovými poli, jako UserName jsou a Password, jsou přístupné ve všech fázích životního cyklu stránky. Ovládací prvek provede všechny změny provedené koncovým uživatelem prostřednictvím TextChanged události aktivované textovými poli.

Platí pro

Viz také