次の方法で共有


ChangePassword Web サーバー コントロールの宣言構文

更新 : 2007 年 11 月

ユーザーが Web サイトのパスワードを変更できるようにするユーザー インターフェイスを作成します。

<asp:ChangePassword
    AccessKey="string"
    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    BorderPadding="integer"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
        Inset|Outset"
    BorderWidth="size"
    CancelButtonImageUrl="uri"
    CancelButtonText="string"
    CancelButtonType="Button|Image|Link"
    CancelDestinationPageUrl="uri"
    ChangePasswordButtonImageUrl="uri"
    ChangePasswordButtonText="string"
    ChangePasswordButtonType="Button|Image|Link"
    ChangePasswordFailureText="string"
    ChangePasswordTitleText="string"
    ConfirmNewPasswordLabelText="string"
    ConfirmPasswordCompareErrorMessage="string"
    ConfirmPasswordRequiredErrorMessage="string"
    ContinueButtonImageUrl="uri"
    ContinueButtonText="string"
    ContinueButtonType="Button|Image|Link"
    ContinueDestinationPageUrl="uri"
    CreateUserIconUrl="uri"
    CreateUserText="string"
    CreateUserUrl="uri"
    CssClass="string"
    DisplayUserName="True|False"
    EditProfileIconUrl="uri"
    EditProfileText="string"
    EditProfileUrl="uri"
    Enabled="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    Font-Bold="True|False"
    Font-Italic="True|False"
    Font-Names="string"
    Font-Overline="True|False"
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
                Large|X-Large|XX-Large"
        Font-Strikeout="True|False"
    Font-Underline="True|False"
    ForeColor="color name|#dddddd"
    Height="size"
    HelpPageIconUrl="uri"
    HelpPageText="string"
    HelpPageUrl="uri"
    ID="string"
    InstructionText="string"
    MailDefinition-BodyFileName="uri"
    MailDefinition-CC="string"
    MailDefinition-From="string"
    MailDefinition-IsBodyHtml="True|False"
    MailDefinition-Priority="Normal|Low|High"
    MailDefinition-Subject="string"
    MembershipProvider="string"
    NewPasswordLabelText="string"
    NewPasswordRegularExpression="string"
    NewPasswordRegularExpressionErrorMessage="string"
    NewPasswordRequiredErrorMessage="string"
    OnCancelButtonClick="CancelButtonClick event handler"
    OnChangedPassword="ChangedPassword event handler"
    OnChangePasswordError="ChangePasswordError event handler"
    OnChangingPassword="ChangingPassword event handler"
    OnContinueButtonClick="ContinueButtonClick event handler"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnSendingMail="SendingMail event handler"
    OnSendMailError="SendMailError event handler"
    OnUnload="Unload event handler"
    PasswordHintText="string"
    PasswordLabelText="string"
    PasswordRecoveryIconUrl="uri"
    PasswordRecoveryText="string"
    PasswordRecoveryUrl="uri"
    PasswordRequiredErrorMessage="string"
    runat="server"
    SkinID="string"
    Style="string"
    SuccessPageUrl="uri"
    SuccessText="string"
    SuccessTitleText="string"
    TabIndex="integer"
    ToolTip="string"
    UserName="string"
    UserNameLabelText="string"
    UserNameRequiredErrorMessage="string"
    Visible="True|False"
    Width="size"
>
        <CancelButtonStyle/>
        <ChangePasswordButtonStyle/>
        <ChangePasswordTemplate>
            <!-- child controls -->
        </ChangePasswordTemplate>
        <ContinueButtonStyle/>
        <FailureTextStyle/>
        <HyperLinkStyle/>
        <InstructionTextStyle/>
        <LabelStyle/>
        <MailDefinition
            BodyFileName="uri"
            CC="string"
            From="string"
            IsBodyHtml="True|False"
            Priority="Normal|Low|High"
            Subject="string"
>
                <EmbeddedObjects>
                        <asp:EmbeddedMailObject
                            Name="string"
                            Path="uri"
                        />
                </EmbeddedObjects>
        </MailDefinition>
        <PasswordHintStyle/>
        <SuccessTemplate>
            <!-- child controls -->
        </SuccessTemplate>
        <SuccessTextStyle/>
        <TextBoxStyle/>
        <TitleTextStyle/>
        <ValidatorTextStyle/>
</asp:ChangePassword>

解説

ChangePassword コントロールは、Web サイトのユーザーが、その Web サイトにログオンするために使用するパスワードを変更できるようにするために、ページ上で使用します。

ms228266.alert_security(ja-jp,VS.90).gifセキュリティに関するメモ :

HTTP を使用したパスワードの伝送は、セキュリティ上の脆弱性となる可能性があります。HTTP による伝送は、悪意のあるユーザーの盗聴や悪用の対象となります。ログイン コントロール使用時のセキュリティを向上させるには、SSL (Secure Sockets Layer) 暗号方式を使用する HTTPS プロトコルを使用して、ポストバック時にユーザーのパスワードが読み取られないようにする必要があります。詳細については、「ログイン コントロールのセキュリティ保護」を参照してください。

ChangePassword コントロールは、MembershipProvider プロパティで定義されているメンバシップ プロバイダを使用して、Web サイトのメンバシップ プロバイダ データ ストアに格納されているパスワードを変更します。メンバシップ プロバイダが割り当てられていない場合、ChangePassword コントロールは、Web.config ファイルの membership セクションで定義されている既定のメンバシップ プロバイダを使用します。

ChangePassword コントロールおよびその他の ASP.NET ログイン コントロールの使い方の詳細については、「ASP.NET ログイン コントロールの概要」を参照してください。

使用例

NewPasswordRegularExpression プロパティを設定して、パスワードが次の基準を満たしているかどうかを確認する正規表現を定義する方法を次のコード例に示します。

  • 文字数が 6 文字を超えているかどうか。

  • 数字が 1 つ以上含まれているかどうか。

  • 特殊文字 (英数字以外の文字) が 1 つ以上含まれているかどうか。

PasswordHintText プロパティに格納されたパスワード要件がユーザーに表示されます。

ユーザーが入力したパスワードが NewPasswordRegularExpression プロパティの要件を満たしていない場合、NewPasswordRegularExpressionErrorMessage プロパティに格納されたテキストがユーザーに表示されます。新しいパスワードが入力されない場合、NewPasswordRequiredErrorMessage プロパティに格納されたテキストがユーザーに表示されます。

ms228266.alert_note(ja-jp,VS.90).gifメモ :

新しいパスワードは、メンバシップ プロバイダMinRequiredPasswordLengthMinRequiredNonAlphanumericCharacters、および PasswordStrengthRegularExpression の各プロパティで設定された最低要件を満たす必要があります。パスワードがこれらの要件を満たしていない場合、ChangePasswordError イベントが発生します。

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

参照

参照

ChangePassword

その他の技術情報

ログイン ツールボックス コントロール