LoginCancelEventArgs.Cancel 속성

정의

이벤트를 취소해야 할지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool Cancel { bool get(); void set(bool value); };
public bool Cancel { get; set; }
member this.Cancel : bool with get, set
Public Property Cancel As Boolean

속성 값

이벤트를 취소해야 하면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 합니다 LoggingIn 사용자가 올바른 형식의 전자 메일 주소를 입력 했는지 확인 하는 이벤트를 UserName 속성입니다. 그렇지 않은 경우, LoggingIn 이벤트 처리기 설정 된 Cancel 속성을 true, 오류 메시지가 표시 됩니다. 예제를 실행 하는.aspx 파일에 대 한 참조를 LoginCancelEventArgs 항목입니다.

public partial class LoginCancelEventArgscs_aspx : System.Web.UI.Page
{

    bool IsValidEmail(string strIn)
    {
        // Return true if strIn is in valid email format.
        return System.Text.RegularExpressions.Regex.IsMatch(strIn, 
            @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
    }
    
    protected void OnLoggingIn(object sender, System.Web.UI.WebControls.LoginCancelEventArgs e)
    {
        if (!IsValidEmail(Login1.UserName))
        {
            Login1.InstructionText = "You must enter a valid email address.";
            e.Cancel = true;
        }
        else
        {
            Login1.InstructionText = String.Empty;
        }
    }
}
Partial Class LoginCancelEventArgsvb_aspx
    Inherits System.Web.UI.Page

    Function IsValidEmail(ByVal strIn As String) As Boolean
        ' Return true if strIn is in valid email format.
        Return Regex.IsMatch(strIn, _
            ("^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"))
    End Function

    Protected Sub OnLoggingIn(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs)
        If Not IsValidEmail(Login1.UserName) Then
            Login1.InstructionText = "You must enter a valid email address."
            e.Cancel = True
        Else
            Login1.InstructionText = String.Empty
        End If
    End Sub

End Class

설명

사용할 수는 Cancel 나타내는 속성을 이벤트에 있는지 여부를 같은 LoggingIn 이벤트를 LoggingOut 이벤트 또는 ChangingPassword 이벤트를 취소 해야 합니다.

적용 대상

추가 정보