Page.SavePageStateToPersistenceMedium(Object) Page.SavePageStateToPersistenceMedium(Object) Page.SavePageStateToPersistenceMedium(Object) Page.SavePageStateToPersistenceMedium(Object) Method


儲存頁面的任何檢視狀態和控制項狀態資訊。Saves any view-state and control-state information for the page.

protected public:
 virtual void SavePageStateToPersistenceMedium(System::Object ^ state);
protected internal virtual void SavePageStateToPersistenceMedium (object state);
abstract member SavePageStateToPersistenceMedium : obj -> unit
override this.SavePageStateToPersistenceMedium : obj -> unit
Protected Friend Overridable Sub SavePageStateToPersistenceMedium (state As Object)


Object Object Object Object

儲存檢視狀態資訊的 ObjectAn Object in which to store the view-state information.


方法會使用屬性所參考System.Web.UI.PageStatePersister Save PageStatePersister之物件的方法,來儲存頁面的檢視狀態和控制狀態資訊。 SavePageStateToPersistenceMediumThe SavePageStateToPersistenceMedium method uses the Save method of the System.Web.UI.PageStatePersister object referenced by the PageStatePersister property to store view-state and control-state information for the page.

ASP.NET 包含PageStatePersister類別的兩個子代,這個HiddenFieldPageStatePersister類別會將狀態資訊儲存在SessionPageStatePersister ASP.NET 網頁所包含的隱藏欄位中,而類別則會在與相關Session聯的物件中儲存狀態。邀請.ASP.NET includes two descendents of the PageStatePersister class, the HiddenFieldPageStatePersister class that saves state information in a hidden field included in the ASP.NET page, and the SessionPageStatePersister class that saves state in the Session object associated with the request. 請注意,使用SessionPageStatePersister類別時,[隱藏 VIEWSTATE] 欄位仍然會轉譯,因為這是用來判斷回傳。Note that when using the SessionPageStatePersister class the hidden VIEWSTATE field is still rendered as this is used to determine post back.

若要將狀態儲存在您選擇的位置中,您應該建立類別的新PageStatePersister子系,將狀態儲存並載入至您選擇的持續性媒體。To save state in the location of your choice, you should create a new descendent of the PageStatePersister class that saves and loads state to the persistence medium of your choice. 如需建立新PageStatePersister物件的範例, PageStatePersister請參閱類別。For an example of creating a new PageStatePersister object, see the PageStatePersister class.

如果您使用 .NET Framework 版本1.0 或1.1,如果您想要將Page狀態儲存在隱藏欄位以外的任何地方,請覆寫此方法。If you are using the .NET Framework version 1.0 or 1.1, override this method if you want to save the Page state in anything other than a hidden field. 如果您選擇這樣做,則也必須覆寫LoadPageStateFromPersistenceMedium方法。If you choose to do so, you must also override the LoadPageStateFromPersistenceMedium method.