Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Latest commit

 

History

History
55 lines (38 loc) · 2.11 KB

File metadata and controls

55 lines (38 loc) · 2.11 KB

Update pages in Visual Studio Code

The following tutorial is based on "Get started with ASP.NET Core Razor Pages in Visual Studio Code" from docs.microsoft.com.

Prerequisites

Update generated Pages

In this tutorial, you're going to learn how to update the generated pages. For example, suppose you want to remove the time from the release date.

  1. Open the Models/Movie.cs file.

  2. Add the following using statements to the top of the file:

    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
  3. Add the following data annotations: [Display(Name = "Release Date")] and [DataType(DataType.Date)] to the ReleaseDate property as shown in the following code:

    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
    namespace RazorPagesMovie.Models;
    
    public class Movie
    {
        public int ID { get; set; }
        public string? Title { get; set; }
    
        [Display(Name = "Release Date")]
        [DataType(DataType.Date)]
        public DateTime ReleaseDate { get; set; }
        
        public string? Genre { get; set; }
    
        [Column(TypeName = "decimal(18, 2)")]
        public decimal Price { get; set; }
    }
  4. Run the app using the dotnet run command.

  5. Navigate to https://localhost:{port}/Movies/Create and notice the changes.

NEXT TUTORIAL: Adding search