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 (36 loc) · 2.13 KB

File metadata and controls

55 lines (36 loc) · 2.13 KB

Update pages in Visual Studio for Mac

The following tutorial is based on "Get started with Razor Pages in ASP.NET Core" 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. Replace the contents of the Movie.cs file with the following code:

    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; }
    }
  • Right click on a red line and select Quick Actions and Refactorings on the [Display] attribute.

  1. Select using System.ComponentModel.DataAnnotations;.

  2. Right click on the remaining red line, select Quick Actions and Refactorings on the [Column] attribute.

  3. Select using System.ComponentModel.DataAnnotations.Schema;.

  4. Run the application by selecting Debug > Start without Debugging on the main menu.

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

NEXT TUTORIAL: Adding search