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


删除服务器控件的所有子控件的视图状态信息。Deletes the view-state information for all the server control's child controls.

 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.