PersistenceModeAttribute 类

定义

定义元数据特性,用于指定如何在设计时将 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
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 窗体控件为属性持久性的控件公开。The Web page designer in Visual Studio does not support the ResetPropertyName method that is optionally exposed by Windows Forms controls for property persistence. 使用ControlPersister类提供的方法对服务器控件进行序列化。Server controls are serialized using methods provided by the ControlPersister class. 这些方法的实现由元数据特性驱动DefaultValueAttribute, 如、 PersistenceModeAttributeDesignerSerializationVisibilityAttributeThe 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

指定属性或事件作为特性保持在服务器控件的开始标记中。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()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式接口实现

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

将一组名称映射为对应的一组调度标识符。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)

适用于

另请参阅