ProfileAutoSaveEventArgs 類別

定義

提供 ProfileAutoSaving 類別之 ProfileModule 事件的資料。

public ref class ProfileAutoSaveEventArgs sealed : EventArgs
public sealed class ProfileAutoSaveEventArgs : EventArgs
type ProfileAutoSaveEventArgs = class
    inherit EventArgs
Public NotInheritable Class ProfileAutoSaveEventArgs
Inherits EventArgs
繼承
ProfileAutoSaveEventArgs

範例

下列程式碼範例顯示 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

備註

委派 ProfileAutoSaveEventHandler 是針對 ProfileAutoSaving 類別的 ProfileModule 事件所定義。 您可以在 ASP.NET 應用程式的 Global.asax 檔案中存取 ProfileAutoSaving 類別的事件 ProfileModule ,如本主題的範例所示。 如果 ProfileManager.AutomaticSaveEnabled 屬性為 true ,則 ProfileAutoSaving 事件會在頁面執行結束時引發。

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

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

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

建構函式

ProfileAutoSaveEventArgs(HttpContext)

建立 ProfileAutoSaveEventArgs 類別的執行個體。

屬性

Context

取得目前要求的 HttpContext

ContinueWithProfileAutoSave

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

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱