ProfileAutoSaveEventHandler Delegasikan

Definisi

Mewakili metode yang akan menangani ProfileAutoSaving peristiwa ProfileModule.

public delegate void ProfileAutoSaveEventHandler(System::Object ^ sender, ProfileAutoSaveEventArgs ^ e);
public delegate void ProfileAutoSaveEventHandler(object sender, ProfileAutoSaveEventArgs e);
type ProfileAutoSaveEventHandler = delegate of obj * ProfileAutoSaveEventArgs -> unit
Public Delegate Sub ProfileAutoSaveEventHandler(sender As Object, e As ProfileAutoSaveEventArgs)

Parameter

sender
Object

Yang ProfileModule mengangkat ProfileAutoSaving peristiwa.

e
ProfileAutoSaveEventArgs

ProfileAutoSaveEventArgs yang berisi data peristiwa.

Contoh

Contoh kode berikut menunjukkan peristiwa yang ProfileAutoSaving disertakan dalam file Global.asax untuk aplikasi ASP.NET.

public void Profile_ProfileAutoSaving(object sender, ProfileAutoSaveEventArgs args)
{
  if (Profile.Cart.HasChanged)
    args.ContinueWithProfileAutoSave = true;
  else
    args.ContinueWithProfileAutoSave = false;
}
Public Sub Profile_ProfileAutoSaving(sender As Object, args As ProfileAutoSaveEventArgs)
  If Profile.Cart.HasChanged Then
    args.ContinueWithProfileAutoSave = True
  Else
    args.ContinueWithProfileAutoSave = False
  End If
End Sub

Keterangan

ProfileAutoSaveEventHandler Delegasi didefinisikan untuk ProfileAutoSaving peristiwa ProfileModule kelas. Anda dapat mengakses ProfileAutoSaving peristiwa ProfileModule kelas di file Global.asax untuk aplikasi ASP.NET Anda, seperti yang ditunjukkan dalam contoh untuk topik ini. Peristiwa ProfileAutoSaving dimunculkan di akhir eksekusi halaman jika AutomaticSaveEnabled properti adalah true.

Metode ini Save secara otomatis menentukan apakah properti yang terdiri dari jenis primitif, string, atau DateTime objek telah diubah, dengan memeriksa IsDirty nilai properti untuk masing-masing SettingsPropertyValue di profil pengguna. Namun, metode ini Save tidak dapat secara eksplisit menentukan apakah kelas kustom telah berubah. Anda dapat menangani ProfileAutoSaving peristiwa untuk menentukan apakah objek kustom telah dimodifikasi dan untuk melanjutkan penyimpanan otomatis untuk objek yang dimodifikasi dan membatalkan penyimpanan otomatis jika tidak ada objek yang telah dimodifikasi.

Untuk membatalkan operasi penyimpanan profil otomatis, atur properti ke ContinueWithProfileAutoSavefalse dalam ProfileAutoSaving peristiwa; jika tidak, atur ContinueWithProfileAutoSave properti ke true.

Mungkin ada beberapa pelanggan untuk peristiwa tersebut ProfileAutoSaving . ProfileModule akan menggunakan nilai terakhir tempat ContinueWithProfileAutoSave properti diatur. Akibatnya, disarankan agar Anda secara eksplisit mengatur ContinueWithProfileAutoSave properti dalam peristiwa tersebut ProfileAutoSaving , terlepas dari apakah Anda membatalkan atau melanjutkan penyimpanan otomatis, karena Anda mungkin perlu menimpa nilai yang ditetapkan oleh pelanggan sebelumnya.

Metode Ekstensi

GetMethodInfo(Delegate)

Mendapatkan objek yang mewakili metode yang diwakili oleh delegasi yang ditentukan.

Berlaku untuk

Lihat juga