PersistenceModeAttribute 類別

定義

定義中繼資料 (Metadata) 屬性,該屬性會指定 ASP.NET 伺服器控制項屬性或事件在設計階段保存至 ASP.NET 網頁的方式。Defines the metadata attribute that specifies how an ASP.NET server control property or event is persisted to an ASP.NET page at design time. 此類別無法獲得繼承。This class cannot be inherited.

public ref class PersistenceModeAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class PersistenceModeAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type PersistenceModeAttribute = class
    inherit Attribute
Public NotInheritable Class PersistenceModeAttribute
Inherits Attribute
繼承
PersistenceModeAttribute
屬性

範例

[PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(TemplateItem))]
public ITemplate MessageTemplate {
   get {
      return _messageTemplate;
   }
   set {
      _messageTemplate = value;
   }
}

<PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(GetType(TemplateItem))> Public Property MessageTemplate() As ITemplate
   Get
      Return _messageTemplate
   End Get
   Set(ByVal Value As ITemplate)
      _messageTemplate = Value
   End Set
End Property

備註

如需使用屬性的詳細資訊,請參閱 屬性For more information about using attributes, see Attributes.

注意

Visual Studio 中的網頁設計工具不支援 ResetPropertyName 屬性持續性 Windows Forms 控制項可選擇性地公開的方法。The Web page designer in Visual Studio does not support the ResetPropertyName method that is optionally exposed by Windows Forms controls for property persistence. 伺服器控制項會使用類別提供的方法進行序列化 ControlPersisterServer controls are serialized using methods provided by the ControlPersister class. 這些方法的執行是由中繼資料屬性(例如、和)所驅動 DefaultValueAttribute PersistenceModeAttribute DesignerSerializationVisibilityAttributeThe implementation of these methods is driven by metadata attributes such as DefaultValueAttribute, PersistenceModeAttribute, and DesignerSerializationVisibilityAttribute.

建構函式

PersistenceModeAttribute(PersistenceMode)

初始化 PersistenceModeAttribute 類別的新執行個體。Initializes a new instance of the PersistenceModeAttribute class.

欄位

Attribute

指定屬性 (Property) 或事件在伺服器控制項的開頭標記中保存為屬性 (Attribute)。Specifies that the property or event persists in the opening tag of the server control as an attribute. 此欄位為唯讀。This field is read-only.

Default

指定 PersistenceModeAttribute 類別的預設型別。Specifies the default type for the PersistenceModeAttribute class. 預設為 PersistenceMode.AttributeThe default is PersistenceMode.Attribute. 此欄位為唯讀。This field is read-only.

EncodedInnerDefaultProperty

指定屬性以 HTML 編碼,並且保存為 ASP.NET 伺服器控制項的唯一內部內容。Specifies that a property is HTML-encoded and persists as the only inner content of the ASP.NET server control. 此欄位為唯讀。This field is read-only.

InnerDefaultProperty

指定屬性保存為 ASP.NET 伺服器控制項的唯一內部內容。Specifies that a property persists as the only inner content of the ASP.NET server control. 此欄位為唯讀。This field is read-only.

InnerProperty

指定屬性保存為伺服器控制項的開頭和結尾標記中的巢狀標記。Specifies that the property persists as a nested tag within the opening and closing tags of the server control. 此欄位為唯讀。This field is read-only.

屬性

Mode

取得 PersistenceMode 列舉型別的目前值。Gets the current value of the PersistenceMode enumeration.

TypeId

在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。When implemented in a derived class, gets a unique identifier for this Attribute.

(繼承來源 Attribute)

方法

Equals(Object)

PersistenceModeAttribute 物件與另一個個物件相比較。Compares the PersistenceModeAttribute object against another object.

GetHashCode()

提供 PersistenceModeAttribute 屬性的雜湊值。Provides a hash value for a PersistenceModeAttribute attribute.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IsDefaultAttribute()

指出 PersistenceModeAttribute 物件是否屬於預設類型。Indicates whether the PersistenceModeAttribute object is of the default type.

Match(Object)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。Maps a set of names to a corresponding set of dispatch identifiers.

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。Retrieves the type information for an object, which can be used to get the type information for an interface.

(繼承來源 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。Provides access to properties and methods exposed by an object.

(繼承來源 Attribute)

適用於

另請參閱