ControlCachePolicy.Duration プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ControlCachePolicy.Duration プロパティの意味・解説 

ControlCachePolicy.Duration プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

キャッシュされたアイテム出力キャッシュ内に存続する時間取得または設定します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim instance As ControlCachePolicy
Dim value As TimeSpan

value = instance.Duration

instance.Duration = value
public TimeSpan Duration { get; set;
 }
public:
property TimeSpan Duration {
    TimeSpan get ();
    void set (TimeSpan value);
}
/** @property */
public TimeSpan get_Duration ()

/** @property */
public void set_Duration (TimeSpan value)

プロパティ
ユーザー コントロール出力キャッシュ内に存続する時間を表す TimeSpan。既定値Zero です。

例外例外
例外種類条件

HttpException

ユーザー コントロールは、BasePartialCachingControl に関連付けられておらず、キャッシュ保存することはできません。

または

Duration プロパティが、コントロール初期化段階および表示段階以外で設定されています。

解説解説
使用例使用例

実行時プログラムかユーザー コントロール動的に読み込み操作する方法次のコード例示します。PartialCachingAttribute 属性SimpleControl というユーザー コントロール適用されます。これは、ユーザー コントロール実行時に PartialCachingControl コントロールによってラップされることを意味しますSimpleControl オブジェクトキャッシュ設定は、関連付けられた ControlCachePolicy オブジェクト (このオブジェクトラップする PartialCachingControl コントロールへの参照使用してアクセス可能) を通じてプログラムか操作できます。この例では、ページ初期化中に Duration プロパティ調べいくつかの条件満たした場合キャッシュ有効期限変更します。このコード例は、ControlCachePolicy クラストピック取り上げているコード例一部分です。

<%@ Page Language="VB" %>
<%@ Reference Control="SimpleControl.ascx" %>
<script language="VB" runat="server">

    ' The following example demonstrates how to load a user control
 dynamically at run time, and
    ' work with the ControlCachePolicy object associated with it.

    ' Loads and displays a UserControl defined in a seperate Logonform.ascx
 file.
    ' You need to have "SimpleControl.ascx" file in 
    ' the same directory as the aspx file. 

    Sub Page_Init(ByVal sender As
 Object, ByVal e As System.EventArgs)
    
        ' Obtain a PartialCachingControl object which wraps the 'LogOnControl'
 user control.
        Dim pcc As PartialCachingControl
        pcc = LoadControl("SimpleControl.ascx")
    
        ' If the control is slated to expire in greater than 60 Seconds
        If (pcc.CachePolicy.Duration > TimeSpan.FromSeconds(60))
 Then
            ' Make it expire faster. Set a new expiration time to 30
 seconds, and make it
            ' an absolute expiration if it isnt already.        
            pcc.CachePolicy.SetExpires(DateTime.Now.Add(TimeSpan.FromSeconds(30)))
            pcc.CachePolicy.SetSlidingExpiration(False)
        End If
        Controls.Add(pcc)
    End Sub
</script>
<%@ Page Language="C#" %>
<%@ Reference Control="SimpleControl.ascx" %>
<script language="C#" runat="server">

// The following example demonstrates how to load a user control dynamically
 at run time, and
// work with the ControlCachePolicy object associated with it.

// Loads and displays a UserControl defined in a seperate Logonform.ascx
 file.
// You need to have "SimpleControl.ascx" file in 
// the same directory as the aspx file. 

void Page_Init(object sender, System.EventArgs e) {
    
    // Obtain a PartialCachingControl object which wraps the 'LogOnControl'
 user control.
    PartialCachingControl pcc = LoadControl("SimpleControl.ascx") as PartialCachingControl;
        
    
    // If the control is slated to expire in greater than 60 Seconds
    if (pcc.CachePolicy.Duration > TimeSpan.FromSeconds(60)
 ) 
    {        
        // Make it expire faster. Set a new expiration time to 30 seconds,
 and make it
        // an absolute expiration if it isnt already.        
        pcc.CachePolicy.SetExpires(DateTime.Now.Add(TimeSpan.FromSeconds(30)));
        pcc.CachePolicy.SetSlidingExpiration(false);
    }                    
    Controls.Add(pcc);
}
</script>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ControlCachePolicy クラス
ControlCachePolicy メンバ
System.Web.UI 名前空間
SetExpires
SetSlidingExpiration



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ControlCachePolicy.Duration プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ControlCachePolicy.Duration プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS