Exportar (0) Imprimir
Expandir todo

DisplayAttribute.Name Property

Gets or sets either a resource name or non-localized text that is used as a member label for elements that are bound to the member.

Namespace:  System.ComponentModel.DataAnnotations
Assembly:  System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)

public string Name { get; set; }

Property Value

Type: System.String
Either a resource name or the non-localized text that is used as a member label for elements that are bound to the member. The resource name is used with the ResourceType property to retrieve localized text that is used as a member label for elements that are bound to the member.

Set the Name property to either a literal non-localized string or to a resource key to use with the ResourceType property to specify a localized name.

Do not use the get accessor of the Name property to retrieve the text to display in your Silverlight application. Instead, use the GetName method to retrieve the name to display. The GetName method returns either the literal non-localized string or the localized string when a resource type has been specified.

The following example shows how to use the DisplayAttribute attribute to set both localized and non-localized display values. A property named EmailAddress includes non-localized display values and a property named LastName includes localized display values that are retrieved from a resource type named DisplayResources.


public class Customer
{
  [Display(Name = "Email Address", 
     Description = "An email address is needed to provide notifications about the order.")]
  public string EmailAddress { get; set; }

  [Display(ResourceType=typeof(DisplayResources), Name="LName", Description="LNameDescription")]
  public string LastName { get; set; }
}


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Adiciones de comunidad

AGREGAR
Mostrar:
© 2015 Microsoft