ProfileService.ValidatingProperties Événement

Définition

Se produit lorsque les propriétés de profil d'un utilisateur sont définies.

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) 

Type d'événement

Exemples

L’exemple suivant montre un gestionnaire d’événements pour l’événement ValidatingProperties . Lorsque la valeur passée pour FirstName la propriété est vide ou null, la FirstName propriété est ajoutée à la FailedProperties collection.

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

Remarques

Vous pouvez créer un gestionnaire d’événements pour l’événement afin de valider les ValidatingProperties valeurs de propriété ou de modifier dynamiquement leurs valeurs. L’événement ValidatingProperties est déclenché lorsque la SetPropertiesForCurrentUser méthode est appelée. Si la valeur d’une propriété échoue à la validation, ajoutez cette propriété à la FailedProperties collection de la ValidatingPropertiesEventArgs classe . Les propriétés qui se trouvent dans la FailedProperties collection ne seront pas enregistrées dans le profil utilisateur.

Vous pouvez ajouter et inscrire le gestionnaire d’événements dans le fichier Global.asax.

S’applique à