LoginCancelEventArgs クラス
定義
キャンセルできるイベントのデータを提供します。Provides data for a cancelable event.
public ref class LoginCancelEventArgs : EventArgs
public class LoginCancelEventArgs : EventArgs
type LoginCancelEventArgs = class
inherit EventArgs
Public Class LoginCancelEventArgs
Inherits EventArgs
- 継承
- 派生
例
次のコード例では、イベントを使用し LoggingIn て、ユーザーが適切な形式の電子メールアドレスをプロパティに入力したことを確認し UserName ます。The following code example uses the LoggingIn event to ensure that the user has entered a well-formed email address in the UserName property. それ以外の場合、 LoggingIn イベントハンドラーは、 Cancel オブジェクトのプロパティをに設定することによって、ログオン試行をキャンセルし LoginCancelEventArgs true
ます。次に、プロパティで指定されたエラーメッセージ InstructionText が表示されます。If not, the LoggingIn event handler cancels the logon attempt by setting the Cancel property of the LoginCancelEventArgs object to true
.Then the error message specified in the InstructionText property is displayed.
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
前の例を実行するために使用できる .aspx ファイルを次に示します。The following is the .aspx file that can be used to run the preceding example.
<%@ Page Language="C#" CodeFile="LoginCancelEventArgs.cs" Inherits="LoginCancelEventArgscs_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="Form1" runat="server">
<asp:Login id="Login1"
runat="server"
onloggingin="OnLoggingIn">
</asp:Login>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="LoginCancelEventArgs.vb" Inherits="LoginCancelEventArgsvb_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="Form1" runat="server">
<asp:Login id="Login1"
runat="server"
onloggingin="OnLoggingIn">
</asp:Login>
</form>
</body>
</html>
注釈
キャンセル可能なイベントは、コンポーネントが、Web サイトへのログオンなど、キャンセルできる操作を実行しようとしているときに発生します。A cancelable event is raised when a component is about to perform an action that can be canceled, such as logging on to a Web site.
クラスは、 LoginCancelEventArgs Cancel イベントをキャンセルする必要があるかどうかを示すプロパティを提供します。The LoginCancelEventArgs class provides the Cancel property to indicate whether the event should be canceled. オブジェクトは、コントロール、コントロール、コントロールなど、キャンセル可能な LoginCancelEventArgs アクションを持つコントロールで使用され Login CreateUserWizard PasswordRecovery ます。A LoginCancelEventArgs object is used with controls that have cancelable actions, such as the Login control, the CreateUserWizard control, and the PasswordRecovery control.
コンストラクター
LoginCancelEventArgs() |
LoginCancelEventArgs プロパティを |
LoginCancelEventArgs(Boolean) |
LoginCancelEventArgs プロパティを指定の値に設定して、Cancel クラスの新しいインスタンスを初期化します。Initializes a new instance of the LoginCancelEventArgs class with the Cancel property set to the specified value. |
プロパティ
Cancel |
イベントをキャンセルするかどうかを示す値を取得または設定します。Gets or sets a value indicating whether the event should be canceled. |
メソッド
Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object. (継承元 Object) |
GetHashCode() |
既定のハッシュ関数として機能します。Serves as the default hash function. (継承元 Object) |
GetType() |
現在のインスタンスの Type を取得します。Gets the Type of the current instance. (継承元 Object) |
MemberwiseClone() |
現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object. (継承元 Object) |
ToString() |
現在のオブジェクトを表す文字列を返します。Returns a string that represents the current object. (継承元 Object) |