WebDisplayNameAttribute 类   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
定义 Web 部件控件属性的友好名称。
public ref class WebDisplayNameAttribute : Attribute[System.AttributeUsage(System.AttributeTargets.Property)]
public class WebDisplayNameAttribute : Attribute[<System.AttributeUsage(System.AttributeTargets.Property)>]
type WebDisplayNameAttribute = class
    inherit AttributePublic Class WebDisplayNameAttribute
Inherits Attribute- 继承
- 属性
示例
下面的代码示例演示如何使用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) ,使用户可以编辑位于WebPartZoneBase区域中的WebPart自定义属性和服务器控件。 为源代码中标记的属性提供了编辑 UI,该属性 (WebBrowsable 来自 WebBrowsableAttribute 类) 。 使用此属性标记属性时,控件 PropertyGridEditorPart 会基于属性的类型创建编辑 UI,并根据需要使用 PropertyDescriptor 对象将每个编辑控件中的值转换为属性的类型。
通过 WebDisplayName 类) 的属性 WebDisplayNameAttribute (,可以指定在编辑 UI 中随每个控件一起显示的标签的文本。
构造函数
| WebDisplayNameAttribute() | 初始化 WebDisplayNameAttribute 类的新实例,而不使用指定的名称。 | 
| WebDisplayNameAttribute(String) | 用指定的显示名称初始化 WebDisplayNameAttribute 类的新实例。 | 
字段
| Default | 表示 WebDisplayNameAttribute 属性设置为空字符串 ("") 的 DisplayName 类的实例。 | 
属性
| 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) |