--------------Display
Name: Display Name
Order: Sort (only for @Html. Editorformodel (), @Html. Displayformodel ())
[Display (name = "Confirm Name", Order = 10001)]
--------------Scaffoldcolumn
Hide properties (only for @Html. Editorformodel (), @Html. Displayformodel ())
[Scaffoldcolumn (False)]
public virtual int st_id {get; set;}
--------------DisplayFormat (formatted data)
Applyformatineditmode: Whether to display strings (for example, ¥10.01)
① Formatting Money
[DisplayFormat (Applyformatineditmode=true, dataformatstring= "{0:c}")]
② format Time
[DisplayFormat (Applyformatineditmode = true, DataFormatString = "{0:yyyy-mm-dd hh:mm:ss}")]
--------------ReadOnly (does not allow data to be changed for this field)
namespaces: Using System.ComponentModel;
[ReadOnly (True)]
--------------DataType (field specific use)
The view will display a password entry box
[DataType (DataType. Password)]
--------------Hiddeninput
Not editable
[Hiddeninput ()]
Hide Form
[Hiddeninput (Displayvalue=false)]
This article is from the "program Ape's Home--hunter" blog, please be sure to keep this source http://962410314.blog.51cto.com/7563109/1603792
MVC3----Data annotations and validation (3) display and edit annotations