ModelMetadata Class
Provides a container for common metadata, for the ModelMetadataProvider class, and for the ModelValidator class for a data model.
Inheritance Hierarchy
System.Object
System.Web.Mvc.ModelMetadata
System.Web.Mvc.DataAnnotationsModelMetadata
Namespace: System.Web.Mvc
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
Syntax
'Declaration
Public Class ModelMetadata
public class ModelMetadata
public ref class ModelMetadata
The ModelMetadata type exposes the following members.
Constructors
Name | Description | |
---|---|---|
ModelMetadata | Initializes a new instance of the ModelMetadata class. |
Top
Properties
Name | Description | |
---|---|---|
AdditionalValues | Gets a dictionary that contains additional metadata about the model. | |
ContainerType | Gets or sets the type of the container for the model. | |
ConvertEmptyStringToNull | Gets or sets a value that indicates whether empty strings that are posted back in forms should be converted to null reference (Nothing in Visual Basic). | |
DataTypeName | Gets or sets meta information about the data type. | |
Description | Gets or sets the description of the model. | |
DisplayFormatString | Gets or sets the display format string for the model. | |
DisplayName | Gets or sets the display name of the model. | |
EditFormatString | Gets or sets the edit format string of the model. | |
HideSurroundingHtml | Gets or sets a value that indicates whether the model object should be rendered using associated HTML elements. | |
IsComplexType | Gets or sets a value that indicates whether the model is a complex type. | |
IsNullableValueType | Gets a value that indicates whether the type is nullable. | |
IsReadOnly | Gets or sets a value that indicates whether the model is read-only. | |
IsRequired | Gets or sets a value that indicates whether the model is required. | |
Model | Gets the value of the model. | |
ModelType | Gets the type of the model. | |
NullDisplayText | Gets or sets the string to display for null values. | |
Properties | Gets a collection of model metadata objects that describe the properties of the model. | |
PropertyName | Gets the property name. | |
Provider | Gets or sets the provider. | |
ShortDisplayName | Gets or sets a short display name. | |
ShowForDisplay | Gets or sets a value that indicates whether the property should be displayed in read-only views such as list and detail views. | |
ShowForEdit | Gets or sets a value that indicates whether the model should be displayed in editable views. | |
SimpleDisplayText | Gets or sets the simple display string for the model. | |
TemplateHint | Gets or sets a hint that suggests what template to use for this model. | |
Watermark | Gets or sets a value that can be used as a watermark. |
Top
Methods
Name | Description | |
---|---|---|
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
FromLambdaExpression<TParameter, TValue> | Gets the metadata from the Expression parameter for the model. | |
FromStringExpression | Gets the metadata from the expression parameter for the model. | |
GetDisplayName | Gets the display name for the model. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetSimpleDisplayText | Returns the simple description of the model. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GetValidators | Gets a list of validators for the model. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Remarks
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.