Thursday, March 28, 2013

PasswordStrength Example Using Ajax In Asp.Net.

In this example i'm explaining how to use PasswordStrength Control Of Ajax Toolkit In Asp.Net With Strength Indicator And BarIndicator.

Passwordstrength ajax asp.net

For this Add latest version ofAjaxControlToolkit.dll in BIN folder of application and place one textbox and passwordstrength control on the aspx page.

Add below mentioned CSS style in stylesheet.css for strength bar to show up.



CSS StyleSheet
01.BarIndicatorweak
02{
03    color:Red;
04    background-color:Red;
05}
06.BarIndicatoraverage
07{
08    color:Blue;
09    background-color:Blue;
10}
11.BarIndicatorgood
12{
13    color:Green;
14    background-color:Green;
15}
16 
17.BarBorder
18{
19    border-style:solid;
20    border-width:1px;
21    padding:2px 2px 2px 2px;
22    width:200px;
23    vertical-align:middle;
24}

Now configure the passwordstrength control as shown below.

<form id="form1" runat="server">
<div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" 
                          runat="server">
</asp:ToolkitScriptManager>

<asp:TextBox ID="TextBox1" runat="server" 
             TextMode="Password">
</asp:TextBox>
        <br />
<asp:PasswordStrength ID="PasswordStrength1" 
                      runat="server" 
         TargetControlID="TextBox1" 
         RequiresUpperAndLowerCaseCharacters="true"
         MinimumNumericCharacters="1" 
         MinimumSymbolCharacters="1" 
         MinimumUpperCaseCharacters="1" 
         PreferredPasswordLength="8"
         DisplayPosition="RightSide" 
         StrengthIndicatorType="Text">
</asp:PasswordStrength>
        <br />
        <br />
<asp:TextBox ID="TextBox2" runat="server" 
             TextMode="Password">
</asp:TextBox>
<asp:PasswordStrength ID="PasswordStrength2" 
                      runat="server" 
        TargetControlID="TextBox2" 
        RequiresUpperAndLowerCaseCharacters="true"
        MinimumNumericCharacters="1" 
        MinimumSymbolCharacters="1" 
        MinimumUpperCaseCharacters="1" 
        PreferredPasswordLength="8"
        DisplayPosition="RightSide" 
        StrengthIndicatorType="BarIndicator" 
        BarBorderCssClass="BarBorder" 
StrengthStyles="BarIndicatorweak;BarIndicatoraverage;BarIndicatorgood;">
</asp:PasswordStrength>
    </div>
    </form>

0 comments:

Post a Comment