ProfileService.ValidatingProperties Evento

Definizione

Si verifica quando le proprietà del profilo di un utente vengono impostate.

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) 

Tipo evento

Esempio

Nell'esempio seguente viene illustrato un gestore eventi per l'evento ValidatingProperties . Quando il valore passato per FirstName la proprietà è vuoto o null, la FirstName proprietà viene aggiunta all'insieme 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

Commenti

È possibile creare un gestore eventi per l'evento ValidatingProperties per convalidare i valori delle proprietà o per modificarne dinamicamente i valori. L'evento ValidatingProperties viene generato quando viene chiamato il SetPropertiesForCurrentUser metodo . Se il valore di una proprietà ha esito negativo, aggiungere tale proprietà all'insieme FailedProperties della ValidatingPropertiesEventArgs classe . Tutte le proprietà presenti nella FailedProperties raccolta non verranno salvate nel profilo utente.

È possibile aggiungere e registrare il gestore eventi nel file Global.asax.

Si applica a