Share via


ProfileService.ValidatingProperties Olay

Tanım

Kullanıcının profil özellikleri ayarlandığında gerçekleşir.

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) 

Olay Türü

Örnekler

Aşağıdaki örnekte olay için bir olay işleyicisi gösterilmektedir ValidatingProperties . özelliği için FirstName geçirilen değer boş olduğunda veya nullFirstName özelliği koleksiyona FailedProperties eklenir.

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

Açıklamalar

Özellik değerlerini doğrulamak veya değerlerini dinamik olarak değiştirmek için olay için ValidatingProperties bir olay işleyicisi oluşturabilirsiniz. ValidatingProperties yöntemi çağrıldığında SetPropertiesForCurrentUser olay tetikleniyor. Bir özelliğin değeri doğrulanamadıysa, bu özelliği sınıfın FailedProperties koleksiyonuna ValidatingPropertiesEventArgs ekleyin. Koleksiyondaki FailedProperties özellikler kullanıcı profiline kaydedilmez.

Olay işleyicisini Global.asax dosyasına ekleyebilir ve kaydedebilirsiniz.

Şunlara uygulanır