ProfileAutoSaveEventHandler 代理人
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表將處理 ProfileAutoSaving 之 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)
參數
- sender
- Object
引發 ProfileModule 事件的 ProfileAutoSaving。
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 ,如本主題的範例所示。 如果 AutomaticSaveEnabled 屬性為 true
,則 ProfileAutoSaving 事件會在頁面執行結束時引發。
方法 Save 會檢查使用者設定檔中的每個屬性值 SettingsPropertyValue ,以 IsDirty 自動判斷由基本類型、字串或 DateTime 物件組成的屬性是否已變更。 不過, Save 方法無法明確判斷自訂類別是否已變更。 您可以處理 ProfileAutoSaving 事件,以判斷自訂物件是否已修改,並且繼續自動儲存已修改的物件,並在未修改物件時取消自動儲存。
若要取消自動設定檔儲存作業,請將 ContinueWithProfileAutoSave 事件中的 ProfileAutoSaving 屬性 false
設定為 ,否則請將 ContinueWithProfileAutoSave 屬性設定為 true
。
事件可能會有多個訂閱者 ProfileAutoSaving 。 ProfileModule將使用 屬性設定為的最後一個值 ContinueWithProfileAutoSave 。 因此,建議您在 事件中 ProfileAutoSaving 明確設定 ContinueWithProfileAutoSave 屬性,不論您要取消還是繼續自動儲存,因為您可能需要覆寫先前訂閱者所設定的值。
擴充方法
GetMethodInfo(Delegate) |
取得表示特定委派所代表之方法的物件。 |
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應