Control.HasChildViewState 属性

定义

获取一个值,该值指示当前服务器控件的子控件是否具有任何已保存的视图状态设置。

protected:
 property bool HasChildViewState { bool get(); };
protected bool HasChildViewState { get; }
member this.HasChildViewState : bool
Protected ReadOnly Property HasChildViewState As Boolean

属性值

Boolean

如果有任何子控件具有已保存的视图状态信息,则为 true;否则为 false

示例

public override void DataBind() 
{
   base.OnDataBinding(EventArgs.Empty);
   // Reset the control's state.
   Controls.Clear();
   // Check for HasChildViewState to avoid unnecessary calls to ClearChildViewState.
   if (HasChildViewState)
      ClearChildViewState();
   ChildControlsCreated = true;
   if (!IsTrackingViewState)
      TrackViewState();
}
Public Overrides Sub DataBind()
   MyBase.OnDataBinding(EventArgs.Empty)
   ' Reset the control's state.
   Controls.Clear()
   ' Check for HasChildViewState to avoid unnecessary calls to ClearChildViewState.
   If HasChildViewState Then
      ClearChildViewState()
   End If
   ChildControlsCreated = True
   If Not IsTrackingViewState Then
      TrackViewState()
   End If
End Sub

注解

可以使用此属性来验证服务器控件的任何子控件是否存储视图状态信息,从而避免对方法进行不必要的调用 ClearChildViewState

适用于

另请参阅