ControlCachePolicy.SetSlidingExpiration メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim instance As ControlCachePolicy Dim useSlidingExpiration As Boolean instance.SetSlidingExpiration(useSlidingExpiration)


SetExpires メソッドと SetSlidingExpiration メソッドを (true を渡して) 使用し、ユーザー コントロールをラップする BasePartialCachingControl コントロールに対して、絶対有効期限ポリシーではなく、スライド式有効期限キャッシュ ポリシーを使用するように指示します。SetExpires メソッドと SetSlidingExpiration メソッドを (false を渡して) 使用し、絶対有効期限ポリシーを指定します。

実行時にプログラムからユーザー コントロールを動的に読み込み、操作する方法を次のコード例に示します。SimpleControl というユーザー コントロールが PartialCachingAttribute 属性で修飾されています。これは、ユーザー コントロールが実行時に PartialCachingControl コントロールによってラップされることを意味します。SimpleControl オブジェクトのキャッシュ設定は、関連付けられた ControlCachePolicy オブジェクト (このオブジェクトをラップする PartialCachingControl コントロールへの参照を使用してアクセス可能) を通じてプログラムから操作できます。この例では、ページの初期化中にキャッシュ設定がチェックされ、条件が満たされた場合は変更されます。このコード例は、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.SetSlidingExpiration メソッドを検索する場合は、下記のリンクをクリックしてください。

- ControlCachePolicy.SetSlidingExpiration メソッドのページへのリンク