ChangePassword.PasswordHintText Proprietà

Definizione

Ottiene o imposta il testo informativo relativo ai requisiti per la creazione di una password per il sito Web.

public:
 virtual property System::String ^ PasswordHintText { System::String ^ get(); void set(System::String ^ value); };
public virtual string PasswordHintText { get; set; }
member this.PasswordHintText : string with get, set
Public Overridable Property PasswordHintText As String

Valore della proprietà

Il testo informativo da visualizzare per i criteri della nuova password. Il valore predefinito è Empty.

Esempio

Nell'esempio di codice seguente viene illustrato come impostare la NewPasswordRegularExpression proprietà per definire un'espressione regolare che controlla le password per assicurarsi che soddisfino i criteri seguenti:

  • Sono maggiori di sei caratteri.

  • Contenere almeno una cifra.

  • Contiene almeno un carattere speciale (non alfanumerico).

I requisiti della password contenuti nella PasswordHintText proprietà vengono visualizzati all'utente.

Se la password immessa dall'utente non soddisfa i criteri, il testo contenuto nella NewPasswordRegularExpressionErrorMessage proprietà viene visualizzato all'utente. Se non viene immessa una nuova password, il testo contenuto nella NewPasswordRequiredErrorMessage proprietà viene visualizzato all'utente.

Nota

La nuova password deve inoltre soddisfare i requisiti minimi impostati dal provider di appartenenze nelle MinRequiredPasswordLengthproprietà , MinRequiredNonAlphanumericCharacterse PasswordStrengthRegularExpression . Se la password non soddisfa questi requisiti, viene generato l'evento ChangePasswordError .

<%@ 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">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <title>Change Password with Validation</title>
</head>
<body>
  <form id="form1" runat="server">
  <div>
  <asp:changepassword id="ChangePassword1" runat="server"
  PasswordHintText = 
    "Please enter a password at least 7 characters long, 
    containing a number and one special character."
  NewPasswordRegularExpression =
    '@\"(?=.{7,})(?=(.*\d){1,})(?=(.*\W){1,})' 
  NewPasswordRegularExpressionErrorMessage =
    "Error: Your password must be at least 7 characters long, 
    and contain at least one number and one special character." >
  </asp:changepassword>
  </div>
  </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">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <title>Change Password with Validation</title>
</head>
<body>
  <form id="form1" runat="server">
  <div>
  <asp:changepassword id="ChangePassword1" runat="server"
  PasswordHintText = "Please enter a password at least 7 characters long, containing a number and one special character."
  NewPasswordRegularExpression = '@\"(?=.{7,})(?=(.*\d){1,})(?=(.*\W){1,})' 
  NewPasswordRegularExpressionErrorMessage = "Your password must be at least 7 characters long, and contain at least one number and one special character.">
  </asp:changepassword>
  </div>
  </form>
</body>
</html>

Commenti

La PasswordHintText proprietà ottiene o imposta testo informativo sui requisiti per la creazione di una password per il sito Web. Utilizzare questa proprietà per descrivere i requisiti per la nuova password specificata nella NewPasswordRegularExpression proprietà .

Il valore di questa proprietà, se impostato, può essere salvato automaticamente in un file di risorse usando uno strumento di progettazione. Per altre informazioni, vedere LocalizableAttributeGlobalizzazione e localizzazione.

Si applica a

Vedi anche