AjaxControlToolkit 微软出的ajax.net 工具使用教程十八 PasswordStrength (密码强度检验)控件的使用

时间:2022-11-28 13:34:36

新建一个AjaxControlToolkitWebSite 项目,把下面的代码复制到你的页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
      <div>
                <br />
        &nbsp; Text Indicators<br />
        &nbsp;
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>&nbsp;<br />
        &nbsp;
        <asp:Label ID="Label1" runat="server" Width="153px"></asp:Label><br />
        <br />
        &nbsp; Status Bar Indicators<br />
        &nbsp;
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
        &nbsp;
        <asp:Label ID="Label2" runat="server" Width="154px"></asp:Label><br />
        <br />
        &nbsp; Help Indicators<br />
        &nbsp;
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox><br />
        &nbsp;
        <asp:Label ID="Label3" runat="server" Width="154px"></asp:Label><br />
            <br />
        <br />
            <ajaxToolkit:PasswordStrength ID="PasswordStrength1" runat="server" TargetControlID="TextBox1"
                DisplayPosition="RightSide"
                StrengthIndicatorType="Text"
                PreferredPasswordLength="10"
                PrefixText="Strength:"
                TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent"
                MinimumNumericCharacters="0"
                MinimumSymbolCharacters="0"
                HelpStatusLabelID="Label1"
                TextCssClass="TextIndicator_TextBox1"
                RequiresUpperAndLowerCaseCharacters="false">
            </ajaxToolkit:PasswordStrength>
            <ajaxToolkit:PasswordStrength ID="PasswordStrength2" runat="server" TargetControlID="TextBox2"
                DisplayPosition="RightSide"
                StrengthIndicatorType="BarIndicator"
                BarIndicatorCssClass="BarIndicator_TextBox2"
                BarBorderCssClass="BarBorder_TextBox2"
                PreferredPasswordLength="10"
                PrefixText="Strength:"
                TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent"
                MinimumNumericCharacters="1"
                MinimumSymbolCharacters="1"
                HelpStatusLabelID="Label2"
                RequiresUpperAndLowerCaseCharacters="true">
            </ajaxToolkit:PasswordStrength>
            <ajaxToolkit:PasswordStrength ID="PasswordStrength3" runat="server"              TargetControlID="TextBox3"
                TextCssClass="TextIndicator_TextBox3"
                DisplayPosition="RightSide"
                StrengthIndicatorType="Text"
                PreferredPasswordLength="20"
                PrefixText="Meets Polixy : "
                MinimumNumericCharacters="2"
                MinimumSymbolCharacters="2"
                HelpStatusLabelID="Label3"
                HelpHandleCssClass="TextIndicator_TextBox3_Handle"
                HelpHandlePosition="BelowRight"
                TextStrengthDescriptions="Not at all; Very Low Compliance; Low Compliance; Average Compliance; Good Compliance; High Compliance; Yes"
                RequiresUpperAndLowerCaseCharacters="true" >
            </ajaxToolkit:PasswordStrength>
        </div>
    </form>   
</body>
</html>