"
 
 
 
ASP.NET (snapshot 2017) Microsoft documentation and samples

Controller methods and views

By Rick Anderson

We have a good start to the movie app, but the presentation is not ideal. We don’t want to see the time (12:00:00 AM in the image below) and ReleaseDate should be two words.

Index view: Release Date is one word (no space) and every movie release date shows a time of 12 AM
Index view: Release Date is one word (no space) and every movie release date shows a time of 12 AM

Open the Models/Movie.cs file and add the highlighted lines shown below:

[!code-csharpMain]

   1:  //#define AddDate 
   2:  #if AddDate
   3:  #region snippet_1
   4:  using System;
   5:  using System.ComponentModel.DataAnnotations;
   6:   
   7:  namespace MvcMovie.Models
   8:  {
   9:      public class Movie
  10:      {
  11:          public int ID { get; set; }
  12:          public string Title { get; set; }
  13:   
  14:          [Display(Name = "Release Date")]
  15:          [DataType(DataType.Date)]
  16:          public DateTime ReleaseDate { get; set; }
  17:          public string Genre { get; set; }
  18:          public decimal Price { get; set; }
  19:      }
  20:  }
  21:  #endregion
  22:  #endif

Build and run the app.

[!INCLUDEadding-model]

Previous - Working with SQLite Next - Add search





Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: //www.vb-net.com/AspNet-DocAndSamples-2017/aspnetcore/tutorials/first-mvc-app-xplat/controller-methods-views.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < THANKS ME>