Control.HasChildViewState Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Property Value
true
if any child controls have saved view state information; otherwise, false
.
Examples
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
Remarks
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.
Applies to
See also
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應