The following tutorial is based on "Get started with Razor Pages in ASP.NET Core" from docs.microsoft.com.
- Visual Studio 2022
- In the Visual Studio Installer, install the following workload:
- ASP.NET and web development
- Tutorial 1- Create a Razor Page application
- Tutorial 2- Add a Model
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.
-
Open the
Models/Movie.cs
file. -
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; } }
-
Press F5 to run the app.
-
Navigate to
https://localhost:{port}/Movies/Create
and notice the changes.
NEXT TUTORIAL: Adding search