Control.HasChildViewState プロパティ
定義
現在のサーバー コントロールの子コントロールが、保存されたビューステートの設定を持っているかどうかを示す値を取得します。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
。それ以外の場合は false
。true
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.