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.

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

適用於

另請參閱