Control.IsTrackingViewState Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient une valeur qui indique si le contrôle serveur enregistre les modifications apportées à son état d’affichage.
protected:
property bool IsTrackingViewState { bool get(); };
protected bool IsTrackingViewState { get; }
member this.IsTrackingViewState : bool
Protected ReadOnly Property IsTrackingViewState As Boolean
Valeur de propriété
true si le contrôle est marqué pour enregistrer son état ; sinon, false.
Exemples
L’exemple suivant remplace la DataBind méthode dans un contrôle serveur ASP.NET personnalisé. Elle commence par appeler la méthode de base OnDataBinding , puis utilise l’objet ControlCollection .
ControlCollection.Clear pour supprimer tous les contrôles enfants et la ClearChildViewState méthode pour supprimer les paramètres d’état d’affichage enregistrés pour ces contrôles enfants. Enfin, la ChildControlsCreated propriété est définie sur true. Le contrôle utilise ensuite la IsTrackingViewState propriété pour déterminer si le suivi des modifications de l’état d’affichage est activé pour le contrôle. Si elle n’est pas activée, la TrackViewState méthode est appelée.
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
Remarques
Pour obtenir un exemple de contrôle serveur personnalisé qui utilise cette propriété, consultez l’exemple de contrôle serveur templated.