ProfileAutoSaveEventArgs.ContinueWithProfileAutoSave 屬性

定義

取得或設定布林值,指出 ProfileModule 是否會自動儲存使用者設定檔。

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

屬性值

如果 ProfileModule 會自動儲存使用者設定檔則為 true,否則為 false。 預設為 true

範例

下列程式碼範例顯示 ProfileAutoSaving ASP.NET 應用程式之 Global.asax 檔案中包含的事件。

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

備註

方法 Save 會檢查使用者設定檔中的每個屬性值 SettingsPropertyValue ,以 IsDirty 自動判斷由基本類型、字串或 DateTime 物件組成的屬性是否已變更。 方法 Save 無法明確判斷自訂類別是否已變更。 您可以使用 ProfileAutoSaving 事件來判斷自訂物件是否已修改,然後在物件已修改時繼續自動儲存,或者如果物件尚未修改,則取消自動儲存。

若要取消自動設定檔儲存作業,請將 ContinueWithProfileAutoSave 事件中的 ProfileAutoSaving 屬性 false 設定為 ,否則請將 ContinueWithProfileAutoSave 屬性設定為 true

事件可能會有多個訂閱者 ProfileAutoSavingProfileModule將使用 屬性設定為的最後一個值 ContinueWithProfileAutoSave 。 因此,建議您在事件中 ProfileAutoSaving 明確設定 ContinueWithProfileAutoSave 屬性,無論是取消還是繼續自動儲存,因為您可能需要覆寫先前訂閱者所設定的值。

適用於

另請參閱