PersistenceMode 列舉

定義

指定 ASP.NET 伺服器控制項屬性或事件,如何以宣告方式保存 (Persist) 在 .aspx 或 .ascx 檔案中。Specifies how an ASP.NET server control property or event is persisted declaratively in an .aspx or .ascx file.

public enum class PersistenceMode
public enum PersistenceMode
type PersistenceMode = 
Public Enum PersistenceMode
繼承
PersistenceMode

欄位

Attribute 0

指定將屬性或事件保存為屬性。Specifies that the property or event persists as an attribute.

EncodedInnerDefaultProperty 3

指定該屬性保存為 ASP.NET 伺服器控制項的唯一內部文字。Specifies that the property persists as the only inner text of the ASP.NET server control. 屬性值以 HTML 編碼。The property value is HTML encoded. 只有字串才能取得這項指定。Only a string can be given this designation.

InnerDefaultProperty 2

指定將保存在 ASP.NET 伺服器控制項中的屬性當成內部文字。Specifies that the property persists in the ASP.NET server control as inner text. 也指示這個屬性是定義為項目的預設屬性。Also indicates that this property is defined as the element's default property. 只有一個屬性可以指定為預設屬性。Only one property can be designated the default property.

InnerProperty 1

指定該屬性保存在 ASP.NET 伺服器控制項中做為巢狀標記。Specifies that the property persists in the ASP.NET server control as a nested tag. 這通常會用於複雜物件,也就是那些本身具有可保存屬性的物件。This is commonly used for complex objects, those that have persistable properties of their own.

範例

下列程式ITemplate代碼範例示範將保存為內部屬性的屬性, 其定義方式PersistenceModeAttribute是將屬性套用至屬性的中繼資料。The following code example demonstrates an ITemplate property that will be persisted as an inner property, as defined by applying the PersistenceModeAttribute attribute to the property's metadata.

[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

適用於

另請參閱