The model metadata is a description of the data type itself and its property members, and the metadata has recursion (if the data is a complex type , the properties of the corresponding metadata describe the attributes of its properties).
Purpose: Model of HTML rendering, model binding, model validation.
Modelmetadata Custom
HTML is rendered based on the properties of the Modelmetadata data, and the Modelmetadata object is created to modify Modelmetadata object properties based on the value of the reflected Read property.
Custom Features |
Properties |
function |
Uihintattribute |
Templatehint |
Template Name |
Hiddeninputattribute |
Hidesurroundinghtml |
Whether to show title |
Scaffoldcolumnattribute |
Showfordisplay Showforedit |
is displayed in the HTML |
Datatypeattribute Displayformatattribute |
DataType DisplayFormat |
Data display style |
Imetadataaware interface that implements an interface that modifies the properties of Modelmetadata when creating Modelmetadata. You can customize the metadata by implementing an interface.
Data templates
Depending on the metadata selection template, the default path for the template is: ~/views/shared or ~/views/{controllername}. Pre-defined templates exist for the system
Book in template |
HTML |
EmailAddress |
Hyper Link to mailto |
Users can customize the template by creating a template in the default path.
Custom HtmlHelper
By extending HtmlHelper
the type, you can customize the label to generate HTML.
public static string TestHtml(this HtmlHelper htmlHelper, string value){ return String.Format("<div>{0}</div>", value);}
The availability of model metadata
What is the source of modelmetadata data? By implementing Modelmetadataprovider abstract classes.
Users can customize ModelMetadataProviders.Current
the registration metadata provided Provider
.
Parsing and rendering of ASP. NET MVC Metadata