ModelMetadata Class


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

Namespace:   System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Inheritance Hierarchy



public class ModelMetadata
public ref class ModelMetadata 
type ModelMetadata = class end
Public Class ModelMetadata


Name Description
System_CAPS_pubmethod ModelMetadata(ModelMetadataProvider, Type, Func<Object>, Type, String)

Initializes a new instance of the ModelMetadata class.


Name Description
System_CAPS_pubproperty AdditionalValues

Gets a dictionary that contains additional metadata about the model.

System_CAPS_pubproperty Container

A reference to the model's container object. Will be non-null if the model represents a property.

System_CAPS_pubproperty ContainerType

Gets or sets the type of the container for the model.

System_CAPS_pubproperty ConvertEmptyStringToNull

Gets or sets a value that indicates whether empty strings that are posted back in forms should be converted to null.

System_CAPS_pubproperty DataTypeName

Gets or sets meta information about the data type.

System_CAPS_pubproperty Description

Gets or sets the description of the model.

System_CAPS_pubproperty DisplayFormatString

Gets or sets the display format string for the model.

System_CAPS_pubproperty DisplayName

Gets or sets the display name of the model.

System_CAPS_pubproperty EditFormatString

Gets or sets the edit format string of the model.

System_CAPS_pubproperty HideSurroundingHtml

Gets or sets a value that indicates whether the model object should be rendered using associated HTML elements.

System_CAPS_pubproperty HtmlEncode

System_CAPS_pubproperty IsComplexType

Gets or sets a value that indicates whether the model is a complex type.

System_CAPS_pubproperty IsNullableValueType

Gets a value that indicates whether the type is nullable.

System_CAPS_pubproperty IsReadOnly

Gets or sets a value that indicates whether the model is read-only.

System_CAPS_pubproperty IsRequired

Gets or sets a value that indicates whether the model is required.

System_CAPS_pubproperty Model

Gets the value of the model.

System_CAPS_pubproperty ModelType

Gets the type of the model.

System_CAPS_pubproperty NullDisplayText

Gets or sets the string to display for null values.

System_CAPS_pubproperty Order

Gets or sets a value that represents order of the current metadata.

System_CAPS_pubproperty Properties

Gets a collection of model metadata objects that describe the properties of the model.

System_CAPS_pubproperty PropertyName

Gets the property name.

System_CAPS_protproperty Provider

Gets or sets the provider.

System_CAPS_pubproperty RequestValidationEnabled

Gets or sets a value that indicates whether request validation is enabled.

System_CAPS_pubproperty ShortDisplayName

Gets or sets a short display name.

System_CAPS_pubproperty ShowForDisplay

Gets or sets a value that indicates whether the property should be displayed in read-only views such as list and detail views.

System_CAPS_pubproperty ShowForEdit

Gets or sets a value that indicates whether the model should be displayed in editable views.

System_CAPS_pubproperty SimpleDisplayText

Gets or sets the simple display string for the model.

System_CAPS_pubproperty TemplateHint

Gets or sets a hint that suggests what template to use for this model.

System_CAPS_pubproperty Watermark

Gets or sets a value that can be used as a watermark.


Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_static FromLambdaExpression<TParameter, TValue>(Expression<Func<TParameter, TValue>>, ViewDataDictionary<TParameter>)

Returns the metadata from the Expression parameter for the model.

System_CAPS_pubmethodSystem_CAPS_static FromStringExpression(String, ViewDataDictionary)

Gets the metadata from the expression parameter for the model.

System_CAPS_pubmethod GetDisplayName()

Gets the display name for the model.

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_protmethod GetSimpleDisplayText()

Returns the simple description of the model.

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod GetValidators(ControllerContext)

Gets a list of validators for the model.

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)


Name Description
System_CAPS_pubfieldSystem_CAPS_static DefaultOrder

The default order value, which is 10000.


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.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

System.Web.Mvc Namespace

Return to top