StateItem.Value プロパティ
アセンブリ: System.Web (system.web.dll 内)

StateBag に格納されている StateItem の値。

StateItem クラスの Value プロパティと IsDirty プロパティを使用して、シンプルなカスタム ASP.NET サーバー コントロール クラス (FirstCustomControl) の状態を保存する方法を次のコード例に示します。ページがサーバーにポストされると、IsDirty プロパティによって、項目が変更されたかどうかがチェックされます。この状態の値は、Value プロパティから取得され、表示されます。
' Create a function that iterates through the view-state ' values stored for this class and returns the ' results as a string. Public Function EnumerateViewState() As String Dim keyName, keyValue As String Dim result As String = [String].Empty Dim myStateItem As StateItem Dim myDictionaryEnumerator As IDictionaryEnumerator = _viewstate.GetEnumerator() While myDictionaryEnumerator.MoveNext() keyName = CStr(myDictionaryEnumerator.Key) myStateItem = CType(myDictionaryEnumerator.Value, StateItem) keyValue = CStr(myStateItem.Value) result = result + "<br>ViewState[" + keyName + "] = " + keyValue End While Return result End Function 'EnumerateViewState End Class 'MyItem
// Create a function that iterates through the view-state // values stored for this class and returns the // results as a string. public string EnumerateViewState() { string keyName, keyValue; string result = String.Empty; StateItem myStateItem; IDictionaryEnumerator myDictionaryEnumerator = _viewstate.GetEnumerator(); while (myDictionaryEnumerator.MoveNext()) { keyName = (string)myDictionaryEnumerator.Key; myStateItem = (StateItem)myDictionaryEnumerator.Value; keyValue = (string)myStateItem.Value; result = result + "<br>ViewState[" + keyName + "] = " + keyValue; } return result; }
// Create a function that iterates through the view-state // values stored for this class and returns the // results as a string. public String EnumerateViewState() { String keyName, keyValue; String result = ""; StateItem myStateItem; IDictionaryEnumerator myDictionaryEnumerator = _viewState.GetEnumerator(); while (myDictionaryEnumerator.MoveNext()) { keyName = (String)myDictionaryEnumerator.get_Key(); myStateItem = (StateItem) myDictionaryEnumerator.get_Value(); keyValue = (String)myStateItem.get_Value(); result = result + "<br>ViewState[" + keyName + "] = " + keyValue; } return result; } //EnumerateViewState

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- StateItem.Value プロパティのページへのリンク