PasswordRecovery.OnUserLookupError(EventArgs) メソッド

定義

UserLookupError イベントを発生させます。

protected:
 virtual void OnUserLookupError(EventArgs ^ e);
protected virtual void OnUserLookupError (EventArgs e);
abstract member OnUserLookupError : EventArgs -> unit
override this.OnUserLookupError : EventArgs -> unit
Protected Overridable Sub OnUserLookupError (e As EventArgs)

パラメーター

e
EventArgs

イベント データを格納している EventArgs

次のコード例では、ユーザーがパスワード確認の質問に対して正しくない回答をOnUserLookupError入力した場合にプロパティをUserNameTitleText変更するメソッドをオーバーライドするカスタム PasswordRecovery コントロールを定義します。

<%@ 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">
    class CustomPasswordRecovery : PasswordRecovery
    {
        override protected void OnAnswerLookupError(EventArgs e)
        {
            QuestionTitleText = "Try again";
            TitleTextStyle.ForeColor = System.Drawing.Color.Red;
            base.OnAnswerLookupError(e);
        }
    }
    
        // Add the custom password recovery control to the page.
        void Page_Init(object sender, EventArgs e)
        {
            CustomPasswordRecovery passwordRecoveryControl = new CustomPasswordRecovery();
        
            passwordRecoveryControl.ID = "passwordRecoveryControl";
        
            PlaceHolder1.Controls.Add(passwordRecoveryControl);
        
        }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
    <p>
        <asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>&nbsp;</p>

</form>
</body>
</html>
<%@ 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">
    Class CustomPasswordRecovery
        Inherits PasswordRecovery
        
        Overloads Sub OnAnswerLookupError(ByVal e As EventArgs)
            QuestionTitleText = "Try again"
            TitleTextStyle.ForeColor = System.Drawing.Color.Red
            MyBase.OnAnswerLookupError(e)
        End Sub
    End Class

    ' Add the custom password recovery control to the page.
    Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
        Dim passwordRecoveryControl As New CustomPasswordRecovery
        
        passwordRecoveryControl.ID = "passwordRecoveryControl"
        
        PlaceHolder1.Controls.Add(passwordRecoveryControl)
        
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
    <p>
        <asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>&nbsp;</p>

</form>
</body>
</html>

注釈

このメソッドは OnUserLookupError 、メンバーシップ プロバイダーが最初の画面で入力したユーザー名を見つけることができない場合に呼び出されます。 既定の実装では、 イベントが UserLookupError 発生します。

イベントを発生させると、イベント ハンドラーがデリゲートから呼び出されます。 詳細については、処理とイベントの発生 を参照してください。

OnUserLookupError メソッドを使用すると、デリゲートを結び付けずに、派生クラスでイベントを処理することもできます。 派生クラスでイベントを処理する場合は、この手法をお勧めします。

注意 (継承者)

派生クラスで OnUserLookupError(EventArgs) をオーバーライドする場合は、登録されているデリゲートがイベントを受け取ることができるように、基本クラスの OnUserLookupError(EventArgs) メソッドを呼び出してください。

適用対象

こちらもご覧ください