TextBox.SaveViewState 方法


儲存自頁面回傳至伺服器以來文字方塊檢視狀態的變更。Saves the changes to the text box view state since the time the page was posted back to the server.

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



包含 Object 檢視狀態變更的 TextBoxThe Object that contains the changes to the TextBox view state. 如果沒有與物件相關聯的檢視狀態,則這個方法會傳回 nullIf no view state is 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's life cycle. 如需詳細資訊,請參閱 IIS 5.0 和6.0 的 ASP.NET 應用程式生命週期總覽For more information, see ASP.NET Application Life Cycle Overview for IIS 5.0 and 6.0.

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