WebDisplayNameAttribute 类

定义

定义 Web 部件控件的属性的友好名称。

public ref class WebDisplayNameAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Property)]
public class WebDisplayNameAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
type WebDisplayNameAttribute = class
    inherit Attribute
Public Class WebDisplayNameAttribute
Inherits Attribute
继承
WebDisplayNameAttribute
属性

示例

下面的代码示例演示如何使用 WebDisplayNameAttribute 特性将显示名称分配给 Web 部件控件上的属性。 为自定义 UserJobType 属性提供一个友好名称“作业类型”,用于在控件中 PropertyGridEditorPart 显示。 此示例是类概述中找到的较大示例的 PropertyGridEditorPart 一部分。

[Personalizable(), WebBrowsable(), WebDisplayName("Job Type"), 
  WebDescription("Select the category that corresponds to your job.")]
public JobTypeName UserJobType
{
  get
  {
    object o = ViewState["UserJobType"];
    if (o != null)
      return (JobTypeName)o;
    else
      return _userJobType;
  }

  set { _userJobType = (JobTypeName)value; }
}
<Personalizable(), WebBrowsable(), WebDisplayName("Job Type"), _
  WebDescription("Select the category that corresponds to your job.")> _
Public Property UserJobType() As JobTypeName
  Get
    Dim o As Object = ViewState("UserJobType")
    If Not (o Is Nothing) Then
      Return CType(o, JobTypeName)
    Else
      Return _userJobType
    End If
  End Get
  Set(ByVal value As JobTypeName)
    _userJobType = CType(value, JobTypeName)
  End Set
End Property

注解

PropertyGridEditorPart控件提供了一个通用用户界面(UI),使用户可以编辑位于WebPart区域中的WebPartZoneBase自定义属性和服务器控件。 为源代码中 WebBrowsable 标记的属性(从 WebBrowsableAttribute 类)提供编辑 UI。 使用此属性标记属性时,控件 PropertyGridEditorPart 会基于属性的类型创建编辑 UI,并根据需要使用 PropertyDescriptor 对象将每个编辑控件中的值转换为属性的类型。

通过 WebDisplayName 属性(来自 WebDisplayNameAttribute 类),可以指定在编辑 UI 中随每个控件一起显示的标签的文本。

构造函数

名称 说明
WebDisplayNameAttribute()

初始化没有指定名称的 WebDisplayNameAttribute 类的新实例。

WebDisplayNameAttribute(String)

使用指定的显示名称初始化类的新实例 WebDisplayNameAttribute

字段

名称 说明
Default

表示将属性设置为空字符串(“)的 WebDisplayNameAttributeDisplayName 的实例。

属性

名称 说明
DisplayName

获取要显示在控件中的 PropertyGridEditorPart 属性的名称。

DisplayNameValue

获取或设置要显示在控件中 PropertyGridEditorPart 的名称。

TypeId

在派生类中实现时,获取此 Attribute的唯一标识符。

(继承自 Attribute)

方法

名称 说明
Equals(Object)

返回一个值,该值指示此实例是否等于指定对象。

GetHashCode()

返回显示名称值的哈希代码。

GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

确定当前实例是否设置为默认值。

Match(Object)

在派生类中重写时,返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

显式接口实现

名称 说明
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,该信息可用于获取接口的类型信息。

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对对象公开的属性和方法的访问。

(继承自 Attribute)

适用于