Control.ClearChildControlState Method


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

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


在建立新的子控制項時(例如,當樣板化資料系結伺服器控制項中的資料系結子控制項)覆寫寫入父控制項的控制項狀態的子控制項狀態資訊時,會使用 ClearChildControlState 方法。The ClearChildControlState method is used when child control-state information written to the parent control's control state is overridden as new child controls are created, such as when data-binding child controls in a templated data-bound server control. 呼叫 SaveControlState 方法之前,將 ClearChildControlState 方法呼叫空白子控制項,可減少必須儲存或傳送之控制項狀態資訊的大小。Calling the ClearChildControlState method to empty child controls before calling the SaveControlState method reduces the size of the control-state information that must be stored or transmitted.

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

若要清除子控制項狀態和檢視狀態,請使用 ClearChildState 方法。To clear both the child control state and view state, use the ClearChildState method.

Applies to

See also