ASP. NET Core Primer-based content backup

Source: Internet
Author: User

Model

Set Primary key inside: [key] can customize the primary key by default is a field named ID type int

Set display format: [DisplayFormat (dataformatstring= "{0: Format shown}", [optional parameter])

Set field display content [Display (Name = "What to display")] Example:

[Display (Name = "Release date")]  Public DateTime releasedate {get; set;}

The foreground will show the publication date on the title bar of the field by default

[required]//is not allowed to be empty [stringlength (60,minimumlength = 5)]//Set the length to 5-60[range (1,100)]//set the input range and limit the input data to a number [DataType ( datatype.currency)]//limit the input data to the currency type of the parameter here DataType inside is an enumeration value of course can also define their own
[RegularExpression(@"^[A-Z]+[a-zA-Z‘‘-‘\s]*$")]//这里放的是正则表达式

The *.cshtml page in view cancels the validation

asp-validation-summary= "TypeName" just give this attribute to cancel it.

In the controller

[validateantiforgerytoken]//Declaration validation validity with   if (modelstate.isvalid) {//something} Validation of validity

  

ASP. NET Core Primer-based content backup

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.