次の方法で共有


UserControl.Cache プロパティ

ユーザー コントロールを格納しているアプリケーションに関連付けられた Cache オブジェクトを取得します。

Public ReadOnly Property Cache As Cache
[C#]
public Cache Cache {get;}
[C++]
public: __property Cache* get_Cache();
[JScript]
public function get Cache() : Cache;

プロパティ値

ユーザー コントロールのデータを格納する Cache オブジェクト。

解説

Cache は、データを格納して後で検索することを可能にし、またアプリケーション全体で共有されます。格納するデータは、現在のページまたはユーザー セッションに依存しません。データの作成が遅い場合は、このプロパティを使用してデータにアクセスして、ページまたはアプリケーションのパフォーマンスを向上させます。Cache の使用方法については、「 アプリケーション データのキャッシュ 」を参照してください。

使用例

[Visual Basic, C#, C++] Cache プロパティを使用して、ユーザー コントロールのアプリケーションに関連付けられている Cache オブジェクトに、Label Web サーバー コントロールである txtValue の Text プロパティ値を格納する例を次に示します。この例では、Cache プロパティを使用して、項目にキー パラメータ値 txtName.Text を割り当てています。

 
Private Sub cmdAdd_Click(objSender As Object, objArgs As EventArgs)
  If txtName.Text <> "" Then
    ' Add this item to the cache.
  Cache(txtName.Text) = txtValue.Text
  End If
End Sub

[C#] 
private void cmdAdd_Click(Object objSender, EventArgs objArgs)
{
    if (txtName.Text != "")
    {
        // Add this item to the cache.
        Cache[txtName.Text] = txtValue.Text;
    }
}
        

[C++] 
private:
void cmdAdd_Click(Object* /*objSender*/, EventArgs* /*objArgs*/)
{
    if (!txtName->Text->Equals(S""))
    {
        // Add this item to the cache.
        Cache->Item[txtName->Text] = txtValue->Text;
    }
}
        

[Visual Basic, C#, C++]

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

必要条件

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

参照

UserControl クラス | UserControl メンバ | System.Web.UI 名前空間 | Cache | Page.Cache