PasswordBox.Password PasswordBox.Password PasswordBox.Password PasswordBox.Password Property


Gets or sets the password currently held by the PasswordBox.

 property System::String ^ Password { System::String ^ get(); void set(System::String ^ value); };
[get: System.Security.SecurityCritical]
[set: System.Security.SecurityCritical]
public string Password { get; set; }
member this.Password : string with get, set
Public Property Password As String

Property Value

A string representing the password currently held by the PasswordBox.

The default value is Empty.


The following example shows how to set the Password property programmatically.

PasswordBox pwdBox = new PasswordBox();
pwdBox.Password = "Open Sesame!";
Dim pwdBox As New PasswordBox()
pwdBox.Password = "Open Sesame!"


When you get the Password property value, you expose the password as plain text in memory. To avoid this potential security risk, use the SecurePassword property to get the password as a SecureString.

Setting this property to null causes the underlying password to be set to Empty.

Applies to

See also