ProfileAutoSaveEventArgs.ContinueWithProfileAutoSave Properti

Definisi

Mendapatkan atau menetapkan nilai yang menunjukkan apakah ProfileModule akan secara otomatis menyimpan profil pengguna.

public:
 property bool ContinueWithProfileAutoSave { bool get(); void set(bool value); };
public bool ContinueWithProfileAutoSave { get; set; }
member this.ContinueWithProfileAutoSave : bool with get, set
Public Property ContinueWithProfileAutoSave As Boolean

Nilai Properti

true ProfileModule jika akan secara otomatis menyimpan profil pengguna; jika tidak, false. Defaultnya adalah true.

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

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. Metode Save ini tidak dapat secara eksplisit menentukan apakah kelas kustom telah berubah. Anda dapat menggunakan ProfileAutoSaving peristiwa untuk menentukan apakah objek kustom telah dimodifikasi lalu melanjutkan penyimpanan otomatis jika objek telah dimodifikasi atau membatalkan penyimpanan otomatis jika objek belum 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 jika ProfileAutoSaving Anda membatalkan atau melanjutkan penyimpanan otomatis, karena Anda mungkin perlu menimpa nilai yang ditetapkan oleh pelanggan sebelumnya.

Berlaku untuk

Lihat juga