ProfileService.ValidatingProperties イベント

定義

ユーザーのプロファイル プロパティが設定されると発生します。

public:
 static event EventHandler<System::Web::ApplicationServices::ValidatingPropertiesEventArgs ^> ^ ValidatingProperties;
public static event EventHandler<System.Web.ApplicationServices.ValidatingPropertiesEventArgs> ValidatingProperties;
member this.ValidatingProperties : EventHandler<System.Web.ApplicationServices.ValidatingPropertiesEventArgs> 
Public Shared Custom Event ValidatingProperties As EventHandler(Of ValidatingPropertiesEventArgs) 

イベントの種類

次の例は、 イベントのイベント ハンドラーを ValidatingProperties 示しています。 プロパティに渡された FirstName 値が空または nullの場合、 FirstName プロパティがコレクションに FailedProperties 追加されます。

void Application_Start(object sender, EventArgs e) 
{
    System.Web.ApplicationServices.ProfileService.ValidatingProperties += new EventHandler<System.Web.ApplicationServices.ValidatingPropertiesEventArgs>(ProfileService_ValidatingProperties);
}

void ProfileService_ValidatingProperties(object sender, System.Web.ApplicationServices.ValidatingPropertiesEventArgs e)
{
    if (String.IsNullOrEmpty((string)e.Properties["FirstName"]))
    {
        e.FailedProperties.Add("FirstName");
    }
}
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    AddHandler System.Web.ApplicationServices.ProfileService.ValidatingProperties, _
      AddressOf ProfileService_ValidatingProperties
End Sub

Sub ProfileService_ValidatingProperties(ByVal sender As Object, ByVal e As System.Web.ApplicationServices.ValidatingPropertiesEventArgs)
    If (String.IsNullOrEmpty(CType(e.Properties("FirstName"), String))) Then
        e.FailedProperties.Add("FirstName")
    End If
End Sub

注釈

イベントのイベント ハンドラー ValidatingProperties を作成して、プロパティ値を検証したり、値を動的に変更したりできます。 イベントは ValidatingProperties 、 メソッドが SetPropertiesForCurrentUser 呼び出されたときに発生します。 プロパティの値が検証に失敗した場合は、そのプロパティを FailedProperties クラスのコレクションに ValidatingPropertiesEventArgs 追加します。 コレクション内の FailedProperties プロパティは、ユーザー プロファイルには保存されません。

イベント ハンドラーは Global.asax ファイルに追加して登録できます。

適用対象