UserControl.CachePolicy 속성

정의

이 사용자 정의 컨트롤의 캐싱 매개 변수 컬렉션에 대한 참조를 가져옵니다.

public:
 property System::Web::UI::ControlCachePolicy ^ CachePolicy { System::Web::UI::ControlCachePolicy ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.UI.ControlCachePolicy CachePolicy { get; }
[<System.ComponentModel.Browsable(false)>]
member this.CachePolicy : System.Web.UI.ControlCachePolicy
Public ReadOnly Property CachePolicy As ControlCachePolicy

속성 값

ControlCachePolicy

ControlCachePolicy의 캐싱 매개 변수를 정의하는 속성이 포함된 UserControl입니다.

특성

예제

다음 코드 예제에서는 사용자 컨트롤을 캐시할 수 있는지 여부를 확인 하는 속성을 사용 SupportsCaching 하는 방법을 보여 줍니다., 그렇다면 10 초 동안 컨트롤을 캐시 하는 속성을 설정 Duration 합니다.

<%@ page language="C#"%>
<%@ register src="SimpleControlcs.ascx" 
             tagname="SimpleControl" 
             tagprefix="uc1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Init(object sender, EventArgs e)
{
  // If the control is already in the cache, calling properties
  // will throw an exception. Make sure the control is available. 
  if (SimpleControl1 != null)
  {
    
    Page.DataBind();
    
    if (SimpleControl1.CachePolicy.SupportsCaching)
    {
      // Set the cache duration to 10 seconds.
      SimpleControl1.CachePolicy.Duration = new TimeSpan(0, 0, 10);
      
    }
  }
}

</script>
<%@ page language="VB"%>
<%@ register src="SimpleControlvb.ascx" 
             tagname="SimpleControl" 
             tagprefix="uc1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    If SimpleControl1 IsNot Nothing Then

      Page.DataBind()
      
      If SimpleControl1.CachePolicy.SupportsCaching Then

        ' Set the cache duration to 10 seconds.

        SimpleControl1.CachePolicy.Duration = New TimeSpan(0, 0, 10)

      End If

    End If

  End Sub
</script>

설명

이 속성은 CachePolicy 클래스 인스턴스에 대한 캐시 매개 변수를 정의합니다 UserControl . 이 CachePolicy 속성은 읽기 전용이지만 반환되는 개체의 ControlCachePolicy 속성을 설정할 수 있습니다.

속성을 CachePolicy 선언적으로 설정할 수 없습니다. 프로그래밍 방식으로 설정해야 합니다.

적용 대상

추가 정보