MVC Learning Four

Source: Internet
Author: User
Tags actionlink

The seventh section describes the addition of the properties of the class in the model, because there are already tables in the database, there are no new columns in the table, so you can delete the database or add a new column to the database, and you can add a class to the controller that initializes the database. and add code to initialize the database in Global.asax

(1) @Html. Displaynamefor (model = model. Title) is the display column name,

(2) @Html. Displayfor (ModelItem = Item. Title) is the contents of the Display column

(3) @Html. ActionLink ("Create New", "create") is a hyperlink that jumps to the Create page in model, referring to the Create method in the controller;

(4) @Html. ActionLink ("edit", "edit", new {id=item.id}) edit the page;

(5) @using (Html.BeginForm ()) {@Html. ValidationSummary (True)} is used for client-side validation, and its html.beginform () indicates that it is displayed on this page

(6) <div class= "Editor-label" >             @ Html.labelfor (model = model). Time) Tags         </div>         <div class= "Editor-field" >             @Html. editorfor ( Model = model. Time) edit box             @Html. validationmessagefor (model = > Model. TIME) Verify legality error display         </div>

Note that the System needs to be referenced when establishing the Movieinitializer class . Data. Entity, and the dropcreatedatabaseifmodelchanges parameter is modified to Moviedbcontext, which defaults to DbContext, otherwise you will be prompted not to rewrite the seed method , the parameters of seed are consistent with dropcreatedatabaseifmodelchanges, and when data is added or deleted, the function deletes the database and creates a new

The eighth section describes the validity of the page validation input information, first of all in the client verification, validation passed after the server to verify. If special validation is required, you only need to modify the additions in the model's class.[DisplayFormat (dataformatstring< Span class= "PLN" > = < span class= "str" > "{0:d}" )][displayformat (dataformatstring = )] is a format validation.

The Nineth section describes the security mechanism, generally do not delete the information directly, but first through the Get method to find the information to be deleted, and then display the details to the page, and then through the user confirmation to delete the Post method to delete information

MVC Learning Four

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.