Control.ClearChildViewState Control.ClearChildViewState Control.ClearChildViewState Control.ClearChildViewState Method

定義

刪除所有伺服器控制項之子控制項的檢視狀態資訊。Deletes the view-state information for all the server control's child controls.

protected:
 void ClearChildViewState();
protected void ClearChildViewState ();
member this.ClearChildViewState : unit -> unit
Protected Sub ClearChildViewState ()

備註

當您在開發樣板化資料系結DataBind伺服器控制項時覆寫方法時,通常會使用這個方法。This method is commonly used when you override the DataBind method when developing templated data-bound server controls. 如果您未呼叫這個方法,則可以將子控制項檢視狀態資訊寫入父伺服器控制項,只有在系結資料時才會覆寫。If you do not call this method, child control view-state information can be written to a parent server control, only to be overridden when the data is bound.

重新建立的Control子控制項時,請ClearChildViewState使用方法來清除子檢視狀態,使其不會不慎套用至新的控制項。When recreating child controls of a Control, use the ClearChildViewState method to clear child view state so that it does not get applied to the new controls inadvertently.

如需使用此方法的詳細資訊, 請參閱如何:建立樣板化的 ASP.NET使用者控制項。For more information about using this method, see How to: Create Templated ASP.NET User Controls.

適用於

另請參閱