This topic has not yet been rated - Rate this topic

ModelMetadata Class

Provides a container for common metadata, for the ModelMetadataProvider class, and for the ModelValidator class for a data model.

System.Object
  System.Web.Mvc.ModelMetadata
    System.Web.Mvc.DataAnnotationsModelMetadata

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)
public class ModelMetadata

The ModelMetadata type exposes the following members.

  Name Description
Public method ModelMetadata Initializes a new instance of the ModelMetadata class.
Top
  Name Description
Public property AdditionalValues Gets a dictionary that contains additional metadata about the model.
Public property ContainerType Gets or sets the type of the container for the model.
Public property ConvertEmptyStringToNull Gets or sets a value that indicates whether empty strings that are posted back in forms should be converted to null.
Public property DataTypeName Gets or sets meta information about the data type.
Public property Description Gets or sets the description of the model.
Public property DisplayFormatString Gets or sets the display format string for the model.
Public property DisplayName Gets or sets the display name of the model.
Public property EditFormatString Gets or sets the edit format string of the model.
Public property HideSurroundingHtml Gets or sets a value that indicates whether the model object should be rendered using associated HTML elements.
Public property IsComplexType Gets or sets a value that indicates whether the model is a complex type.
Public property IsNullableValueType Gets a value that indicates whether the type is nullable.
Public property IsReadOnly Gets or sets a value that indicates whether the model is read-only.
Public property IsRequired Gets or sets a value that indicates whether the model is required.
Public property Model Gets the value of the model.
Public property ModelType Gets the type of the model.
Public property NullDisplayText Gets or sets the string to display for null values.
Public property Order Gets or sets a value that represents order of the current metadata.
Public property Properties Gets a collection of model metadata objects that describe the properties of the model.
Public property PropertyName Gets the property name.
Protected property Provider Gets or sets the provider.
Public property RequestValidationEnabled Gets or sets a value that indicates whether request validation is enabled.
Public property ShortDisplayName Gets or sets a short display name.
Public property ShowForDisplay Gets or sets a value that indicates whether the property should be displayed in read-only views such as list and detail views.
Public property ShowForEdit Gets or sets a value that indicates whether the model should be displayed in editable views.
Public property SimpleDisplayText Gets or sets the simple display string for the model.
Public property TemplateHint Gets or sets a hint that suggests what template to use for this model.
Public property Watermark Gets or sets a value that can be used as a watermark.
Top
  Name Description
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method Static member FromLambdaExpression<TParameter, TValue> Returns the metadata from the Expression parameter for the model.
Public method Static member FromStringExpression Gets the metadata from the expression parameter for the model.
Public method GetDisplayName Gets the display name for the model.
Public method GetHashCode (Inherited from Object.)
Protected method GetSimpleDisplayText Returns the simple description of the model.
Public method GetType (Inherited from Object.)
Public method GetValidators Gets a list of validators for the model.
Protected method MemberwiseClone (Inherited from Object.)
Public method ToString (Inherited from Object.)
Top
  Name Description
Public field Static member DefaultOrder The default order value, which is 10000.
Top

This class is used by the DataAnnotationsModelMetadataProvider class, which is the default model metadata provider for MVC. By default, ModelMetadata objects are constructed using data taken from attributes, primarily from the System.ComponentModel and System.ComponentModel.DataAnnotations namespaces.

You can specify an alternative model metadata provider. For more information about ModelMetadata, see the entry ASP.NET MVC 2 Templates, Part 2: ModelMetadata on Brad Wilson's blog.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)