The following are some of the common properties of the Ajax PasswordStrength control:
- BarBorderCssClass: Used to set custom css class for border of PasswordStrength control.
- BarIndicatorCssClass: Used to set custom css class for password strength Bar Indicator.
- CalculationWeightings: Set the Calculation Weightings for strength Bar Indicator.
- DisplayPosition: Sets the display position for strength indicator ,default is right.
- HelpHandleCssClass: Sets the CSS class for help link.
- HelpHandlePosition: Sets the help link position,default is AboveRight.
- HelpStatusLabelID: sets the help status Lable Id.
- MinimumLowerCaseCharacters: Defines the how many minimum lower case letter in password.
- MinimumNumericCharacters: Defines how many numeric characters in password.
- MinimumSymbolCharacters: Defines minimum occurrences of Special symbol characters.
- MinimumUpperCaseCharacters: Defines the how many minimum upper case letter in password.
- PreferredPasswordLength: Defines the length of the password.
- PrefixText: Defines prefix for password which should be start from prefix.
- RequiresUpperAndLowerCaseCharacters: Specifies whether the password must required both upper and lower case characters .if yes then required ,if no then not required.
- StrengthIndicatorType: Defines the strenght indicator type whether it will be BarIndicator or Text.
- StrengthStyles: Used to specify CSS class for strength indicator.
- TextCssClass: Used to specify CSS class for text.
- TextStrengthDescriptions: Used to specify text to describe password strength such as good,strong ,very strong etc.
- TextStrengthDescriptionStyles: Used to specify CSS class for strength indicator text description.
Now let us see the preceding explanation by creating a sample web application as in the following:
- "Start" - "All Programs" - "Microsoft Visual Studio 2010".
- "File" - "New Project" - "C#" - "Empty WebSite" (to avoid adding a master page).
- Provide the website a name: "UsingPasswordStrengthValidator" or another as you wish and specify the location.
- Then right-click on the Solution Explorer and select "Add New Item" and Add Web Form.
- Drag and drop one Button, a TextBox onto the
- Add the reference of Ajax Control toolkit from nuget or directly from the official website of Ajax Control toolkit. To add using the nuget package manager, type ajax control toolkit in NuGet package manager search and click on search button. Here's a screenshot for making things clear:
7. After installing, the Ajax control will get added automatically into the toolbox. Now click on upper right hand corner of the textbox and add the PasswordStrength control to textbox control as in the following screenshot:
Now the default.aspx page source code will look like the following:
Now let us set PasswordStrength control properties:
- PreferredPasswordLength : 10
- MinimumLowerCaseCharacters : 2
- MinimumUpperCaseCharacters : 2
- MinimumNumericCharacters : 2
- RequiresUpperAndLowerCaseCharacters : True
- StrengthIndicatorType : Text.
Now let us run the application, and enter some different text as we defined in properties. Here's the screenshot:
After entering one more character (.), the strength of the password will look like the following screenshot:
Now enter the passwords which is like the one defined under the properties of PasswordStrength control. After that it will show the following message:
The complete Default.aspx code is given below:
From all the above examples we learned about the Password Strength control.
- Please add Ajax control toolkit dll reference as shown in this article.
- Don't forget to give the reference of Script manager.
From all the preceding examples you have learned about the Password Strength control. I hope this article is useful for all readers. If you have a suggestion then please contact me or mention it in the comments section.