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

Dim instance As ControlCachePolicy Dim value As TimeSpan value = instance.Duration instance.Duration = value
/** @property */ public TimeSpan get_Duration () /** @property */ public void set_Duration (TimeSpan value)
ユーザー コントロールが出力キャッシュ内に存続する時間を表す TimeSpan。既定値は Zero です。



実行時にプログラムからユーザー コントロールを動的に読み込み、操作する方法を次のコード例に示します。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>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からControlCachePolicy.Duration プロパティを検索する場合は、下記のリンクをクリックしてください。

- ControlCachePolicy.Duration プロパティのページへのリンク