StateBag.IStateManager.SaveViewState 方法

定義

儲存自頁面回傳至伺服器以來 StateBag 物件的變更。Saves the changes to the StateBag object since the time the page was posted back to the server.

 virtual System::Object ^ System.Web.UI.IStateManager.SaveViewState() = System::Web::UI::IStateManager::SaveViewState;
object IStateManager.SaveViewState ();
Function SaveViewState () As Object Implements IStateManager.SaveViewState

傳回

包含 StateBag 檢視狀態變更的物件。The object that contains the changes to the view state of the StateBag. 如果沒有任何變更,或是 StateBag中沒有任何 StateItem 項目,這個方法會傳回 nullIf there are no changes, or there are no StateItem elements in the StateBag, this method returns null.

實作

備註

這個方法主要由控制項開發人員使用。This method is primarily used by control developers.

「檢視狀態」是伺服器控制項屬性值的累積。View state is the accumulation of the values of a server control's properties. 這些值會自動放在伺服器控制項的 ViewState 屬性中,這是 StateBag 類別的實例。These values are automatically placed in the server control's ViewState property, which is an instance of the StateBag class. 這個屬性的值接著會在伺服器控制項生命週期的 [儲存狀態] 階段之後保存到字串物件中。This property's value is then persisted to a string object after the save state stage of the server control life cycle. 如需詳細資訊,請參閱ASP.NET Web 服務器控制項For more information, see ASP.NET Web Server Controls.

儲存 view 狀態時,會將這個字串物件當做儲存在 HTML Hidden 元素中的變數傳回給用戶端。When view state is saved, this string object is returned to the client as a variable that is stored in an HTML Hidden element. 當您撰寫自訂伺服器控制項時,您可以藉由覆寫這個方法並修改伺服器控制項的 ViewState 屬性來提升效率。When you author custom server controls, you can improve efficiency by overriding this method and modifying your server control's ViewState property. 如需詳細資訊,請參閱ASP.NET Web 服務器控制項ASP.NET 狀態管理總覽For more information, see ASP.NET Web Server Controls and ASP.NET State Management Overview.

適用於

另請參閱