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.


SavePageStateToPersistenceMedium方法會使用Save方法System.Web.UI.PageStatePersister所參考物件PageStatePersister屬性來儲存頁面的檢視狀態和控制項狀態資訊。The 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包含在 ASP.NET 頁面中,隱藏欄位中儲存狀態資訊的類別和SessionPageStatePersister儲存狀態中的類別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.