I need to create a function that is only necessary inside one cshtml file. You can think of my situation as ASP.NET page methods, which are min web services implemented in a
In ASP.NET Core Razor Pages, you can combine C# and HTML in the function:
@model PagerModel
@{
}
@functions
{
void PagerNumber(int pageNumber, int currentPage)
{
if (pageNumber == currentPage)
{
@pageNumber
}
else
{
@pageNumber
}
}
}
@PagerNumber(1,2) @PagerNumber(2,2) @PagerNumber(3,2)