語言

WebDisplayNameAttribute 建構函式

定義

初始化 WebDisplayNameAttribute 類別的新執行個體。

多載

名稱 Description
WebDisplayNameAttribute()

初始化一個未指定名稱的 WebDisplayNameAttribute 類別新實例。

WebDisplayNameAttribute(String)

初始化一個以指定顯示名稱的新類別實例 WebDisplayNameAttribute 。

WebDisplayNameAttribute()

初始化一個未指定名稱的 WebDisplayNameAttribute 類別新實例。

public:
 WebDisplayNameAttribute();
public WebDisplayNameAttribute();
Public Sub New ()

備註

WebDisplayNameAttribute建構子將屬性設DisplayName為空字串(“)。

適用於

WebDisplayNameAttribute(String)

初始化一個以指定顯示名稱的新類別實例 WebDisplayNameAttribute 。

public:
 WebDisplayNameAttribute(System::String ^ displayName);
public WebDisplayNameAttribute(string displayName);
new System.Web.UI.WebControls.WebParts.WebDisplayNameAttribute : string -> System.Web.UI.WebControls.WebParts.WebDisplayNameAttribute
Public Sub New (displayName As String)

參數

displayName
String

PropertyGridEditorPart在 .

範例

以下程式碼範例示範如何利用該 WebDisplayNameAttribute 屬性為 Web Parts 控制項上的屬性指派顯示名稱。 自訂 UserJobType 屬性會被指定為友善名稱「Job Type」,以便在控制項中 PropertyGridEditorPart 顯示。 名稱由建造者賦予 WebDisplayNameAttribute 。 這個例子是班級概述中另一個較大範例 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

備註

建構子將 WebDisplayNameAttribute 屬性 DisplayName 設定為 displayName。 參數 displayName 是會出現在 PropertyGridEditorPart 控制項中的值。

適用於