次の方法で共有


Triplet.First フィールド

Triplet クラスを使用してサーバー コントロールのビューステートに追加される最初のオブジェクトを表します。

Public First As Object
[C#]
public object First;
[C++]
public: Object* First;
[JScript]
public var First : Object;

使用例

[Visual Basic] 次のコードは、 Triplet クラスを使用してビューステートから 2 つのオブジェクトを取得します。その後、 First フィールドが表すオブジェクトを文字列に変換し、firstValue という名前の変数に割り当てます。この値は、これを含むページに書き込まれます。

 
' When a button is clicked, this method retrieves values from
' view state that were added using an instance of the Triplet class.
Sub btnRetrieve_Click(sender As [Object], e As EventArgs)
    ' Create variables to store the retrieved strings.
    Dim firstValue As String
    Dim secondValue As String
    Dim thirdValue As String

    ' Use the empty Triplet constructor to create a new instance
    ' of the class, and then set it equal to the value stored
    ' in view state.
    Dim o As Object = ViewState("triplet1")

    If o is Nothing
       triLabel2.Text = "There is no triplet1 key stored in view state."
    Else
       Dim myTriplet1 As Triplet = CType(o, Triplet)
       firstValue = CStr(myTriplet1.First)
       secondValue = CStr(myTriplet1.Second)
       thirdValue = CStr(myTriplet1.Third)

       triLabel2.Text = "You retrieved " & _
        firstValue & ", " & _
        secondValue & ", and " & _
        thirdValue & " from view state."
    End If

End Sub 'btnRetrieve_Click

[C#, C++, JScript] C#、C++、および JScript のサンプルはありません。Visual Basic のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

参照

Triplet クラス | Triplet メンバ | System.Web.UI 名前空間