MVC3----Data annotations and validation (3) display and edit annotations

Source: Internet
Author: User

--------------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

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.