5.5. Let Users Change PasswordsNote: Allow users to change their passwords via the ChangePassword control. Changing passwords is another common task performed by users of a web site. ASP.NET 2.0 has replaced the mundane task of writing low-level code to change passwords with a brand new ChangePassword control. 5.5.1. How do I do that?In this lab, you will create a page that allows users to change their passwords. You will use the ChangePassword control to do the work. You will create a new Web Form in the restricted Members folder so that authenticated users can change their passwords.
Figure 5-23. Error in changing the password5.5.2. What about......adding regular expressions to ensure that the user's new password is of a certain length and complexity? You can do this by adding a NewPasswordRegularExpression attribute to the <asp:changepassword> element (in Source View): <asp:changepassword runat="server" PasswordHintText = "Password must be 8 characters long and includes two numbers and two special character." NewPasswordRegularExpression = '@\"(?=.{8,})(?=(.*\d){2,})(?=(.*\W){2,})' NewPasswordRegularExpressionErrorMessage= "Error: Your password must be 8 characters long and includes two numbers and two special character." > </asp:changepassword> If you apply the Elegant scheme to the ChangePassword control, it will appear like Figure 5-24 during runtime (shown displaying the different error messages). Figure 5-24. The ChangePassword control with the error messages5.5.3. Where can I learn more?For more information on using regular expressions for pattern matching, check out the book Mastering Regular Expressions by Jeffrey E. F. Friedl (O'Reilly). |