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

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

BasePartialCachingControl.CachePolicy プロパティ

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

ラップされたユーザー コントロール関連付けられた ControlCachePolicy オブジェクト取得します

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

Public ReadOnly Property
 CachePolicy As ControlCachePolicy
Dim instance As BasePartialCachingControl
Dim value As ControlCachePolicy

value = instance.CachePolicy
public ControlCachePolicy CachePolicy { get;
 }
public:
property ControlCachePolicy^ CachePolicy {
    ControlCachePolicy^ get ();
}
/** @property */
public ControlCachePolicy get_CachePolicy ()
public function get CachePolicy
 () : ControlCachePolicy

プロパティ
ラップされたユーザー コントロールキャッシュ関連プロパティ格納する ControlCachePolicy

解説解説
使用例使用例

実行時プログラムかユーザー コントロール動的に読み込み操作する方法次のコード例示します。この例は、3 つの部分構成されます。

この例を正常に実行するには、ユーザー コントロール ファイル (.ascx)、それに対応する分離コード ファイル (.cs または .vb)、およびそのユーザー コントロール (.aspx) をホストする Web フォーム ページが同じディレクトリ内にあることを確認してください

この例の最初部分では、PartialCachingAttributeLogOnControl という名前のユーザー コントロール適用する方法示してます。これは、ユーザー コントロール実行時に PartialCachingControl コントロールによってラップされることを意味しますLogOnControl オブジェクトキャッシュ設定は、関連付けられた ControlCachePolicy オブジェクト (このオブジェクトラップする PartialCachingControl への参照使用してアクセス可能) を通じてプログラムか操作できます。この例では、ページ初期化中にキャッシュ設定チェックされ条件満たされ場合変更されます。

Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls

<PartialCaching(100)> _
Public Class LogOnControl
   Inherits UserControl

   Public user As TextBox
   Public password As TextBox

End Class 'LogOnControl
using System;
using System.Web.UI;
using System.Web.UI.WebControls;

[PartialCaching(100)]
public class LogOnControl:UserControl
{
    public TextBox user;
    public TextBox password;
}

この例の 2 番目の部分には、前述の例でユーザー コントロールキャッシュ方法を示すために使用するユーザー コントロール示してます。

<%@ control inherits = "LogOnControl"
 src = "LogOnControl.vb" %>
<form runat=server>
<table style=font: 10pt verdana;border-width:1;border-style:solid;border-color:black;"
 cellspacing=15>
<tr>
<td><b>Login: </b></td>
<td><ASP:TextBox id="user" runat="server"/></td>
</tr>
<tr>
<td><b>Password: </b></td>
<td><ASP:TextBox id="password" TextMode="Password"
 runat="server"/></td>
</tr>
<tr>
</tr>
</table>
</form>
<%@ control inherits = "LogOnControl" src = "LogOnControl.cs"
 %>
<form runat="server">
<table style=font: 10pt verdana;border-width:1;border-style:solid;border-color:black;"
 cellspacing=15>
<tr>
<td><b>Login: </b></td>
<td><asp:TextBox id="user" runat="server"/></td>
</tr>
<tr>
<td><b>Password: </b></td>
<td><asp:TextBox id="password" TextMode="Password" runat="server"/></td>
</tr>
<tr>
</tr>
</table>
</form>

この例の 3 番目の部分では、Web フォーム ページから LogOnControl ユーザー コントロール使用する方法示してます。

<%@ Page Language="VB" Debug = "true"%>
<%@ Reference Control="Logonformvb.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 "Logonform.ascx" and "LogOnControl.vb"
 file in 
    ' the same directory as the aspx file.
    Sub Page_Init(ByVal Sender As
 Object, ByVal e As EventArgs)

        ' Obtain a PartialCachingControl object which wraps the 'LogOnControl'
 user control.
        Dim pcc As PartialCachingControl
        pcc = CType(LoadControl("Logonform.vb.ascx"),
 PartialCachingControl)
    
        Dim cacheSettings As ControlCachePolicy
        cacheSettings = pcc.CachePolicy
    
        ' If the control is slated to expire in greater than 60 Seconds
        If (cacheSettings.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.        
            cacheSettings.SetExpires(DateTime.Now.Add(TimeSpan.FromSeconds(30)))
            cacheSettings.SetSlidingExpiration(False)
        End If
        Controls.Add(pcc)

    End Sub ' Page_Init
              
</script>
<%@ Page Language="C#" Debug = "true"%>
<%@ Reference Control="Logonformcs.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 "Logonform.ascx" and "LogOnControl.cs"
 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("Logonform.cs.ascx") as PartialCachingControl;
        
    
    ControlCachePolicy cacheSettings = pcc.CachePolicy;
    
    // If the control is slated to expire in greater than 60 Seconds
    if (cacheSettings.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.        
        cacheSettings.SetExpires(DateTime.Now.Add(TimeSpan.FromSeconds(30)));
        cacheSettings.SetSlidingExpiration(false);
    }                    
    Controls.Add(pcc);
}
</script>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BasePartialCachingControl クラス
BasePartialCachingControl メンバ
System.Web.UI 名前空間
CachePolicy


このページでは「.NET Framework クラス ライブラリ リファレンス」からBasePartialCachingControl.CachePolicy プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からBasePartialCachingControl.CachePolicy プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からBasePartialCachingControl.CachePolicy プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

「BasePartialCachingControl.CachePolicy プロパティ」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS