LoginCancelEventArgs.Cancel プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As LoginCancelEventArgs Dim value As Boolean value = instance.Cancel instance.Cancel = value
/** @property */ public boolean get_Cancel () /** @property */ public void set_Cancel (boolean value)
イベントをキャンセルする場合は true。それ以外の場合は false。


LoggingIn イベントを使用して、ユーザーが整形式の電子メール アドレスを UserName プロパティに入力したことを確認するコード例を次に示します。整形式の電子メール アドレスが入力されなかった場合は、LoggingIn イベント ハンドラが Cancel プロパティを true に設定し、エラー メッセージが表示されます。この例の実行に使用できる .aspx ファイルについては、LoginCancelEventArgs のトピックを参照してください。
Partial Class LoginCancelEventArgsvb_aspx Inherits System.Web.UI.Page Function IsValidEmail(ByVal strIn As String) As Boolean ' Return true if strIn is in valid e-mail 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 e-mail address." e.Cancel = True Else Login1.InstructionText = String.Empty End If End Sub End Class
public partial class LoginCancelEventArgscs_aspx : System.Web.UI.Page { bool IsValidEmail(string strIn) { // Return true if strIn is in valid e-mail 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 e-mail address."; e.Cancel = true; } else { Login1.InstructionText = String.Empty; } } }

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- LoginCancelEventArgs.Cancel プロパティのページへのリンク