Using Code-Behind Files with Razor Pages
Explore how to use code-behind files with ASP.NET Core Razor Pages to separate HTML markup from C# code. Learn to create organized, maintainable web pages by managing data and logic in code-behind classes while rendering dynamic content.
We'll cover the following...
We'll cover the following...
Sometimes, it is better to separate the HTML markup from the data and executable code because it is more organized. Razor Pages allows us to do this by putting the C# code in code-behind class files. They have the same name as the .cshtml file but end with .cshtml.cs.
Creating a Razor Page for a list of suppliers
We will now create a Razor Page that shows a list of suppliers. In this example, we are focusing on learning ...