Bearbeiten

Freigeben über


PartialCachingAttribute Constructors

Definition

Initializes a new instance of the PartialCachingAttribute class.

Overloads

PartialCachingAttribute(Int32)

Initializes a new instance of the PartialCachingAttribute class with the specified duration assigned to the user control to be cached.

PartialCachingAttribute(Int32, String, String, String)

Initializes a new instance of the PartialCachingAttribute class, specifying the caching duration, any GET and POST values, control names, and custom output caching requirements used to vary the cache.

PartialCachingAttribute(Int32, String, String, String, Boolean)

Initializes a new instance of the PartialCachingAttribute class, specifying the caching duration, any GET and POST values, control names, custom output caching requirements used to vary the cache, and whether the user control output can be shared with multiple pages.

PartialCachingAttribute(Int32, String, String, String, String, Boolean)

Initializes a new instance of the PartialCachingAttribute class, specifying the caching duration, any GET and POST values, control names, custom output caching requirements used to vary the cache, the database dependencies, and whether the user control output can be shared with multiple pages.

PartialCachingAttribute(Int32)

Initializes a new instance of the PartialCachingAttribute class with the specified duration assigned to the user control to be cached.

public:
 PartialCachingAttribute(int duration);
public PartialCachingAttribute (int duration);
new System.Web.UI.PartialCachingAttribute : int -> System.Web.UI.PartialCachingAttribute
Public Sub New (duration As Integer)

Parameters

duration
Int32

The amount of time, in seconds, a user control should remain in the output cache.

Examples

The following code example demonstrates how the PartialCachingAttribute(Int32) constructor can be applied to a user control. In the example, the constructor is used to indicate that the user control can be cached and to specify the caching duration. This code example is part of a larger example provided for the PartialCachingAttribute class.

// Set the PartialCachingAttribute.Duration property to 20 seconds.
[PartialCaching(20)]
public partial class ctlMine : UserControl
' Set the PartialCachingAttribute.Duration property to 20 seconds.
<PartialCaching(20)> _
Partial Class ctlMine
    Inherits UserControl

Applies to

PartialCachingAttribute(Int32, String, String, String)

Initializes a new instance of the PartialCachingAttribute class, specifying the caching duration, any GET and POST values, control names, and custom output caching requirements used to vary the cache.

public:
 PartialCachingAttribute(int duration, System::String ^ varyByParams, System::String ^ varyByControls, System::String ^ varyByCustom);
public PartialCachingAttribute (int duration, string varyByParams, string varyByControls, string varyByCustom);
new System.Web.UI.PartialCachingAttribute : int * string * string * string -> System.Web.UI.PartialCachingAttribute
Public Sub New (duration As Integer, varyByParams As String, varyByControls As String, varyByCustom As String)

Parameters

duration
Int32

The amount of time, in seconds, that the user control is cached.

varyByParams
String

A semicolon-separated list of strings used to vary the output cache. By default, these strings correspond to a query string value sent with GET method attributes or to a parameter sent using the POST method. When this attribute is set to multiple parameters, the output cache contains a different version of the requested document for each specified parameter. Possible values include "none", "*", and any valid query string or POST parameter name.

varyByControls
String

A semicolon-separated list of strings used to vary the output cache. These strings represent fully qualified names of properties on a user control. When this parameter is used for a user control, the user control output is varied to the cache for each specified user control property.

varyByCustom
String

Any text that represents custom output caching requirements. If this parameter is given a value of "browser", the cache is varied by browser name and major version information. If a custom string is entered, you must override the GetVaryByCustomString(HttpContext, String) method in your application's Global.asax file.

Examples

The following code example demonstrates how the PartialCachingAttribute(Int32, String, String, String) constructor can be applied to a user control. In the example, the constructor is used to indicate that the user control can be cached, specify the caching duration as 20 seconds, and specify a control named state for which the user control output will be varied.

// Set the PartialCachingAttribute.Duration property to
// 20 seconds and the PartialCachingAttribute.VaryByControls
// property to the ID of the server control to vary the output by.
// In this case, it is state, the ID assigned to a DropDownList
// server control.
[PartialCaching(20, null, "state", null)]
' Set the PartialCachingAttribute.Duration property to
' 20 seconds and the PartialCachingAttribute.VaryByControls
' property to the ID of the server control to vary the output by.
' In this case, it is state, the ID assigned to a DropDownList
' server control.
<PartialCaching(20, Nothing, "state", Nothing)> _
Public Class ctlSelect
    Inherits UserControl

Applies to

PartialCachingAttribute(Int32, String, String, String, Boolean)

Initializes a new instance of the PartialCachingAttribute class, specifying the caching duration, any GET and POST values, control names, custom output caching requirements used to vary the cache, and whether the user control output can be shared with multiple pages.

public:
 PartialCachingAttribute(int duration, System::String ^ varyByParams, System::String ^ varyByControls, System::String ^ varyByCustom, bool shared);
public PartialCachingAttribute (int duration, string varyByParams, string varyByControls, string varyByCustom, bool shared);
new System.Web.UI.PartialCachingAttribute : int * string * string * string * bool -> System.Web.UI.PartialCachingAttribute
Public Sub New (duration As Integer, varyByParams As String, varyByControls As String, varyByCustom As String, shared As Boolean)

Parameters

duration
Int32

The amount of time, in seconds, that the user control is cached.

varyByParams
String

A semicolon-separated list of strings used to vary the output cache. By default, these strings correspond to a query string value sent with GET method attributes, or a parameter sent using the POST method. When this attribute is set to multiple parameters, the output cache contains a different version of the requested document for each specified parameter. Possible values include "none", "*", and any valid query string or POST parameter name.

varyByControls
String

A semicolon-separated list of strings used to vary the output cache. These strings represent fully qualified names of properties on a user control. When this parameter is used for a user control, the user control output is varied to the cache for each specified user control property.

varyByCustom
String

Any text that represents custom output caching requirements. If this parameter is given a value of "browser", the cache is varied by browser name and major version information. If a custom string is entered, you must override the GetVaryByCustomString(HttpContext, String) method in your application's Global.asax file.

shared
Boolean

true to indicate that the user control output can be shared with multiple pages; otherwise, false.

Applies to

PartialCachingAttribute(Int32, String, String, String, String, Boolean)

Initializes a new instance of the PartialCachingAttribute class, specifying the caching duration, any GET and POST values, control names, custom output caching requirements used to vary the cache, the database dependencies, and whether the user control output can be shared with multiple pages.

public:
 PartialCachingAttribute(int duration, System::String ^ varyByParams, System::String ^ varyByControls, System::String ^ varyByCustom, System::String ^ sqlDependency, bool shared);
public PartialCachingAttribute (int duration, string varyByParams, string varyByControls, string varyByCustom, string sqlDependency, bool shared);
new System.Web.UI.PartialCachingAttribute : int * string * string * string * string * bool -> System.Web.UI.PartialCachingAttribute
Public Sub New (duration As Integer, varyByParams As String, varyByControls As String, varyByCustom As String, sqlDependency As String, shared As Boolean)

Parameters

duration
Int32

The amount of time, in seconds, that the user control is cached.

varyByParams
String

A semicolon-separated list of strings used to vary the output cache. By default, these strings correspond to a query string value sent with GET method attributes, or a parameter sent using the POST method. When this attribute is set to multiple parameters, the output cache contains a different version of the requested document for each specified parameter. Possible values include "none", "*", and any valid query string or POST parameter name.

varyByControls
String

A semicolon-separated list of strings used to vary the output cache. These strings represent fully qualified names of properties on a user control. When this parameter is used for a user control, the user control output is varied to the cache for each specified user control property.

varyByCustom
String

Any text that represents custom output caching requirements. If this parameter is given a value of "browser", the cache is varied by browser name and major version information. If a custom string is entered, you must override the GetVaryByCustomString(HttpContext, String) method in your application's Global.asax file.

sqlDependency
String

A delimited list of database names and table names that, when changed, explicitly expire a cache entry in the ASP.NET cache. These database names match those SQL Server cache dependencies identified in your Web configuration section.

shared
Boolean

true to indicate that the user control output can be shared with multiple pages; otherwise, false.

Applies to