Login.Password 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會取得使用者輸入的密碼。
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
屬性值
使用者輸入的密碼。 預設值為 null。
- 屬性
範例
以下程式碼範例將該 Password 屬性傳遞給自訂的認證方法。
<%@ 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>
備註
該 Password 屬性包含使用者輸入的密碼。 密碼是明文。 欲了解更多資訊,請參閱 網頁應用的基本安全實務。
備註
如果你以 UserName 程式方式操作 OR Password 屬性,務必在頁面生命週期的正確時機進行。 和 Password 的UserName值在相Page_Load位期間不可得,但在相Pre_Render位中卻存在。
Login 以文字框表示的控制屬性,如 UserName 和 Password,在頁面生命週期的所有階段皆可存取。 控制項會透過文字框觸發事件,擷取終端使用者 TextChanged 所做的任何變更。