StateBag.IsItemDirty(String) 메서드

정의

StateItem를 호출한 이후로 StateBag 개체에 저장된 TrackViewState() 개체가 수정되었는지 여부를 확인합니다.

public:
 bool IsItemDirty(System::String ^ key);
public bool IsItemDirty (string key);
member this.IsItemDirty : string -> bool
Public Function IsItemDirty (key As String) As Boolean

매개 변수

key
String

확인할 항목의 키입니다.

반환

Boolean

해당 항목이 수정되었으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.

예제

다음 코드 예제는 IsItemDirty 메서드.

// Implement the SaveViewState method. If the StateBag
// that stores the MyItem class's view state contains
// a value for the message property and if the value
// has changed since the TrackViewState method was last 
// called, all view state for this class is deleted, 
// using the StateBag.Clear method,and the new value is added.
object IStateManager.SaveViewState()
{
    // Check whether the message property exists in 
    // the ViewState property, and if it does, check
    // whether it has changed since the most recent
    // TrackViewState method call.
    if (!((IDictionary)_viewstate).Contains("message") || _viewstate.IsItemDirty("message"))
    {
        _viewstate.Clear();
        // Add the _message property to the StateBag.
        _viewstate.Add("message", _message);
    }
    return ((IStateManager)_viewstate).SaveViewState();
}

' Implement the SaveViewState method. If the StateBag
' that stores the MyItem class's view state contains
' a value for the message property and if the value
' has changed since the TrackViewState method was last 
' called, all view state for this class is deleted, 
' using the StateBag.Clear method,and the new value is added.
Function SaveViewState() As Object Implements IStateManager.SaveViewState
    ' Check whether the message property exists in 
    ' the ViewState property, and if it does, check
    ' whether it has changed since the most recent
    ' TrackViewState method call.
    If Not CType(_viewstate, IDictionary).Contains("message") OrElse _viewstate.IsItemDirty("message") Then
        _viewstate.Clear()
        ' Add the _message property to the StateBag.
        _viewstate.Add("message", _message)
    End If
    Return CType(_viewstate, IStateManager).SaveViewState()
End Function 'IStateManager.SaveViewState


설명

또한 이 메서드는 매개 변수가 key 개체에 StateBag 없는 경우에도 반환 false 합니다.

적용 대상

추가 정보