Parsing and rendering of ASP. NET MVC Metadata

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.