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) ,可讓使用者編輯位於 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)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

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

擷取物件的類型資訊,可以用來取得介面的類型資訊。

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

擷取物件提供的類型資訊介面數目 (0 或 1)。

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

提供物件所公開的屬性和方法的存取權。

(繼承來源 Attribute)

適用於