Bagikan melalui


ValidatingPropertiesEventArgs.Properties Properti

Definisi

Mendapatkan kumpulan nama dan nilai properti profil untuk divalidasi.

public:
 property System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ Properties { System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ get(); };
public System.Collections.Generic.IDictionary<string,object> Properties { get; }
member this.Properties : System.Collections.Generic.IDictionary<string, obj>
Public ReadOnly Property Properties As IDictionary(Of String, Object)

Nilai Properti

Nama dan nilai properti profil untuk divalidasi.

Contoh

Contoh berikut menunjukkan penanganan aktivitas untuk peristiwa tersebut ValidatingProperties . Ketika nilai yang diteruskan untuk FirstName properti kosong atau null, FirstName properti ditambahkan ke FailedProperties koleksi.

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

Keterangan

Properti Properties mengembalikan IDictionary objek yang berisi nama dan nilai properti profil yang akan diatur untuk pengguna. Jika Anda membuat penanganan aktivitas untuk peristiwa tersebut ValidatingProperties , Anda dapat mengambil properti untuk divalidasi dari Properties properti . Jika ada nilai yang gagal divalidasi, tambahkan ke FailedProperties properti . Metode SetPropertiesForCurrentUser mengembalikan koleksi di FailedProperties properti sehingga Anda dapat menentukan properti mana yang gagal divalidasi.

Berlaku untuk