Parameter.SaveViewState 方法


儲存自頁面回傳至伺服器以來 Parameter 物件檢視狀態的變更。Saves the changes to the Parameter object's view state since the time the page was posted back to the server.

 virtual System::Object ^ SaveViewState();
protected virtual object SaveViewState ();
abstract member SaveViewState : unit -> obj
override this.SaveViewState : unit -> obj
Protected Overridable Function SaveViewState () As Object



包含 Object 檢視狀態變更的 ParameterThe Object that contains the changes to the Parameter view state. 如果沒有與物件關聯的檢視狀態,則這個方法會傳回 nullIf there is no view state associated with the object, this method returns null.


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

檢視狀態是伺服器控制項屬性值的累積。View state is the accumulation of the values of a server control's properties. 這些值會自動放在伺服器控制項的 ViewState 屬性中,也就是類別的實例 StateBagThese 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.

當儲存檢視狀態時,此字串物件會傳回至用戶端,做為儲存在 HTML 元素中的變數 hiddenWhen view state is saved, this string object is returned to the client as a variable that is stored in an HTML hidden element. 當您撰寫自訂伺服器控制項時,您可以藉由覆寫這個方法和修改伺服器控制項的屬性,來改善效率 ViewStateWhen you author custom server controls, you can improve efficiency by overriding this method and modifying your server control's ViewState property.