共用方式為


PasswordRecovery.OnVerifyingAnswer(LoginCancelEventArgs) 方法

定義

引發 VerifyingAnswer 事件。

protected:
 virtual void OnVerifyingAnswer(System::Web::UI::WebControls::LoginCancelEventArgs ^ e);
protected virtual void OnVerifyingAnswer (System.Web.UI.WebControls.LoginCancelEventArgs e);
abstract member OnVerifyingAnswer : System.Web.UI.WebControls.LoginCancelEventArgs -> unit
override this.OnVerifyingAnswer : System.Web.UI.WebControls.LoginCancelEventArgs -> unit
Protected Overridable Sub OnVerifyingAnswer (e As LoginCancelEventArgs)

參數

e
LoginCancelEventArgs

CancelEventArgs,其中包含事件資料。

範例

下列程式代碼範例會建立實作 方法的OnVerifyingAnswer自定義PasswordRecovery控件。 自定義類別只會呼叫 方法的 OnVerifyingAnswer 基底實作。

<%@ 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 OnVerifyingAnswer(System.Web.UI.WebControls.LoginCancelEventArgs e)
        {
            base.OnVerifyingAnswer(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 OnVerifyingAnswer(ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs)
            MyBase.OnVerifyingAnswer(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>

備註

OnVerifyingAnswer 使用者對密碼復原確認問題的解答傳送給要驗證的成員資格提供者之前,會呼叫 方法。 默認實作會 VerifyingAnswer 引發 事件。

引發事件會透過委派叫用此事件處理常式。 如需詳細資訊,請參閱 處理和引發事件

OnVerifyingAnswer 方法也允許衍生類別處理事件,而不用附加委派。 這是在衍生類別中處理事件的慣用技巧。

給繼承者的注意事項

當在衍生類別中覆寫 OnVerifyingAnswer(LoginCancelEventArgs) 時,請確定呼叫基底類別的 OnVerifyingAnswer(LoginCancelEventArgs) 方法,使已註冊的委派能接收到事件。

適用於

另請參閱