DisplayAttribute.Description 屬性

定義

取得或設定 UI 中用來顯示描述的值。

public:
 property System::String ^ Description { System::String ^ get(); void set(System::String ^ value); };
public string Description { get; set; }
public string? Description { get; set; }
member this.Description : string with get, set
Public Property Description As String

屬性值

UI 中用來顯示描述的值。

範例

下列範例會示範如何設定 Description 屬性。

[MetadataType(typeof(EmployeeMD))]  
public partial class Employee {  
    public class EmployeeMD {  
        [Display(Name = "Last Name", Order = -9,   
        Prompt = "Enter Last Name", Description="Emp Last Name")]  
        public object LastName { get; set; }  

        [Display(Name = "Manager", AutoGenerateFilter=false)]  
        public object Employee1 { get; set; }  
    }  
}  
<MetadataType(GetType(EmployeeMD))>  _  
Public Class Employee  

    Public Class EmployeeMD  

        <Display(Name:="Last Name", Order:=-9, _  
           Prompt:="Enter Last Name", Description:="Emp Last Name")>  _  
        Public Property LastName As Object  
        End Property  

        <Display(Name:="Manager", AutoGenerateFilter:=false)>  _  
        Public Property Employee1 As Object  
        End Property  
    End Class  
End Class  

備註

請勿使用這個屬性來取得 屬性的值 Description 。 請改用 GetDescription 方法。

屬性 Description 通常用來做為工具提示或描述UI元素,而該元素會使用這個屬性系結至成員。 動態數據編輯.ascx 範本會將描述顯示為文字輸入欄位中的工具提示。 null值或空字串有效。

適用於