ChangePassword Costruttore

Definizione

Inizializza una nuova istanza della classe ChangePassword.

public:
 ChangePassword();
public ChangePassword ();
Public Sub New ()

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 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>

Si applica a

Vedi anche