Control.HasChildViewState Control.HasChildViewState Control.HasChildViewState Control.HasChildViewState Property

定义

获取一个值,该值指示当前服务器控件的子控件是否具有任何已保存的视图状态设置。Gets a value indicating whether the current server control's child controls have any saved view-state settings.

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

属性值

如果有任何子控件具有已保存的视图状态信息,则为 true;否则为 falsetrue if any child controls have saved view state information; otherwise, 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验证服务器控件的所有子控件是否存储视图状态信息,从而避免不必要的方法调用。You can avoid unnecessary calls to the ClearChildViewState method by using this property to verify that any child controls of the server control are storing view-state information.

适用于

另请参阅