Control.IsTrackingViewState プロパティ
定義
サーバー コントロールがビューステートの変更を保存しているかどうかを示す値を取得します。Gets a value that indicates whether the server control is saving changes to its view state.
protected:
property bool IsTrackingViewState { bool get(); };
protected bool IsTrackingViewState { get; }
member this.IsTrackingViewState : bool
Protected ReadOnly Property IsTrackingViewState As Boolean
プロパティ値
コントロールがその状態を保存するようにマークされている場合は true
。それ以外の場合は false
。true
if the control is marked to save its state; otherwise, false
.
例
次の例では、 DataBind カスタム ASP.NET サーバーコントロールのメソッドをオーバーライドします。The following example overrides the DataBind method in a custom ASP.NET server control. まず、基本メソッドを呼び出し、 OnDataBinding 次にオブジェクトを使用し ControlCollection
ます。It begins by calling the base OnDataBinding method and then uses the ControlCollection
object. ControlCollection.Clearすべての子コントロールを削除するメソッドと、 ClearChildViewState それらの子コントロールの保存されているビューステート設定を削除するメソッド。ControlCollection.Clear method to delete all the child controls and the ClearChildViewState method to delete any saved view-state settings for those child controls. 最後に、 ChildControlsCreated プロパティがに設定され true
ます。Finally, the ChildControlsCreated property is set to true
. コントロールは、プロパティを使用して、 IsTrackingViewState コントロールに対してビューステート変更の追跡が有効になっているかどうかを判断します。The control then uses the IsTrackingViewState property to determine whether view-state change tracking is enabled for the control. 有効になっていない場合は、 TrackViewState メソッドが呼び出されます。If it is not enabled, the TrackViewState method is called.
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
注釈
このプロパティを使用するサンプルのカスタムサーバーコントロールについては、「テンプレートサーバーコントロールの例」を参照してください。For a sample custom server control that uses this property, see Templated Server Control Example