PartialCachingAttribute 建構函式

定義

初始化 PartialCachingAttribute 類別的新執行個體。

多載

名稱 Description
PartialCachingAttribute(Int32)

初始化一個新的類別實例 PartialCachingAttribute ,並指定使用者控制項的快取時間。

PartialCachingAttribute(Int32, String, String, String)

初始化該類別的新實例 PartialCachingAttribute ,指定快取持續時間、任何 GET 與 POST 值、控制名稱,以及用於調整快取的自訂輸出快取需求。

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

初始化該類別的新實例 PartialCachingAttribute ,指定快取持續時間、任意 GET 值、 POST 控制名稱、自訂輸出快取需求以調整快取,以及使用者控制輸出是否能與多個頁面共享。

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

初始化類別的新實例 PartialCachingAttribute ,指定快取持續時間、任何 GET 值、 POST 控制名稱、自訂輸出快取需求以調整快取、資料庫依賴性,以及使用者控制輸出是否能與多個頁面共享。

PartialCachingAttribute(Int32)

初始化一個新的類別實例 PartialCachingAttribute ,並指定使用者控制項的快取時間。

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

參數

duration
Int32

使用者控制應該保留在輸出快取中的時間(以秒計)。

範例

以下程式碼範例示範如何 PartialCachingAttribute(Int32) 將建構子應用於使用者控制項。 在此範例中,建構子用來表示使用者控制項可快取並指定快取持續時間。 此程式碼範例是本類別更大範例 PartialCachingAttribute 的一部分。

// 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

適用於

PartialCachingAttribute(Int32, String, String, String)

初始化該類別的新實例 PartialCachingAttribute ,指定快取持續時間、任何 GET 與 POST 值、控制名稱,以及用於調整快取的自訂輸出快取需求。

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)

參數

duration
Int32

使用者控制被快取的時間(以秒計)。

varyByParams
String

一個以分號分隔的字串清單用於變化輸出快取。 預設情況下,這些字串對應於使用 GET 方法屬性傳送的查詢字串值,或是使用 POST 方法傳送的參數。 當此屬性設定為多個參數時,輸出快取會包含每個指定參數不同版本的請求文件。 可能的值包括「none」、「*」,以及任何有效的查詢字串或 POST 參數名稱。

varyByControls
String

一個以分號分隔的字串清單用於變化輸出快取。 這些字串代表使用者控制項中屬性的完整限定名稱。 當此參數用於使用者控制項時,使用者控制的輸出會根據每個指定的使用者控制屬性調整至快取。

varyByCustom
String

任何代表自訂輸出快取需求的文字。 若此參數被設定為「browser」,快取會依瀏覽器名稱及主要版本資訊而變化。 如果輸入自訂字串,你必須覆寫應用程式 Global.asax 檔案中的該 GetVaryByCustomString(HttpContext, String) 方法。

範例

以下程式碼範例示範如何 PartialCachingAttribute(Int32, String, String, String) 將建構子應用於使用者控制項。 在此範例中,建構子用來表示使用者控制項可以快取,指定快取持續時間為 20 秒,並指定一個控制 state 項,使用者控制輸出將因此變化。

// 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

適用於

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

初始化該類別的新實例 PartialCachingAttribute ,指定快取持續時間、任意 GET 值、 POST 控制名稱、自訂輸出快取需求以調整快取,以及使用者控制輸出是否能與多個頁面共享。

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)

參數

duration
Int32

使用者控制被快取的時間(以秒計)。

varyByParams
String

一個以分號分隔的字串清單用於變化輸出快取。 預設情況下,這些字串對應於以 GET 方法屬性傳送的查詢字串值,或是使用該 POST 方法傳送的參數。 當此屬性設定為多個參數時,輸出快取會包含每個指定參數不同版本的請求文件。 可能的值包括「none」、「*」,以及任何有效的查詢字串或 POST 參數名稱。

varyByControls
String

一個以分號分隔的字串清單用於變化輸出快取。 這些字串代表使用者控制項中屬性的完整限定名稱。 當此參數用於使用者控制項時,使用者控制的輸出會根據每個指定的使用者控制屬性調整至快取。

varyByCustom
String

任何代表自訂輸出快取需求的文字。 若此參數被設定為「browser」,快取會依瀏覽器名稱及主要版本資訊而變化。 如果輸入自訂字串,你必須覆寫應用程式 Global.asax 檔案中的該 GetVaryByCustomString(HttpContext, String) 方法。

shared
Boolean

true以表示使用者控制輸出可與多個頁面共享;否則,。 false

適用於

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

初始化類別的新實例 PartialCachingAttribute ,指定快取持續時間、任何 GET 值、 POST 控制名稱、自訂輸出快取需求以調整快取、資料庫依賴性,以及使用者控制輸出是否能與多個頁面共享。

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)

參數

duration
Int32

使用者控制被快取的時間(以秒計)。

varyByParams
String

一個以分號分隔的字串清單用於變化輸出快取。 預設情況下,這些字串對應於以 GET 方法屬性傳送的查詢字串值,或是使用該 POST 方法傳送的參數。 當此屬性設定為多個參數時,輸出快取會包含每個指定參數不同版本的請求文件。 可能的值包括「none」、「*」,以及任何有效的查詢字串或 POST 參數名稱。

varyByControls
String

一個以分號分隔的字串清單用於變化輸出快取。 這些字串代表使用者控制項中屬性的完整限定名稱。 當此參數用於使用者控制項時,使用者控制的輸出會根據每個指定的使用者控制屬性調整至快取。

varyByCustom
String

任何代表自訂輸出快取需求的文字。 若此參數被設定為「browser」,快取會依瀏覽器名稱及主要版本資訊而變化。 如果輸入自訂字串,你必須覆寫應用程式 Global.asax 檔案中的該 GetVaryByCustomString(HttpContext, String) 方法。

sqlDependency
String

一個分隔的資料庫名稱與資料表名稱清單,當這些名稱變更時,會明確地使 ASP.NET 快取中的快取項目過期。 這些資料庫名稱與你網頁設定區塊中識別的 SQL Server 快取相依性相符。

shared
Boolean

true以表示使用者控制輸出可與多個頁面共享;否則,。 false

適用於