razor-pages

Using a checkbox list with Razor Pages for input to DB

有些话、适合烂在心里 提交于 2021-01-24 12:22:29
问题 I want one of my inputs in a form to come from a list of checkboxes that the user selects. I've been going at this for several hours now, and I still don't understand what I need to do for this. Why is there so much help for MVC on this topic and hardly any for Razor? .cshtml <form method="post"> <label asp-for="ServiceRqLd.JobType" class="control-label"></label> <div class="form-check-inline"> @for (var i = 0; i < Model.JobTypes.Count(); i++) { <div class="form-check"> <input asp-for="@Model

Using a checkbox list with Razor Pages for input to DB

落爺英雄遲暮 提交于 2021-01-24 12:22:21
问题 I want one of my inputs in a form to come from a list of checkboxes that the user selects. I've been going at this for several hours now, and I still don't understand what I need to do for this. Why is there so much help for MVC on this topic and hardly any for Razor? .cshtml <form method="post"> <label asp-for="ServiceRqLd.JobType" class="control-label"></label> <div class="form-check-inline"> @for (var i = 0; i < Model.JobTypes.Count(); i++) { <div class="form-check"> <input asp-for="@Model

How can I add a function that all Razor Pages can access?

一笑奈何 提交于 2021-01-15 06:38:12
问题 Using Razor Pages ASP.Net Core, I have some functions that I'd like to use on every page. I guess this used to be done with App_Code, but that no longer seems to work in Core. How can I accomplish this in Asp.Net Core Razor Pages? 回答1: Option 1 - DI 1 - Create the service class with the relevant functionality public class FullNameService { public string GetFullName(string first, string last) { return $"{first} {last}"; } } 2- Register the service in startup services.AddTransient

How can I add a function that all Razor Pages can access?

蹲街弑〆低调 提交于 2021-01-15 06:36:31
问题 Using Razor Pages ASP.Net Core, I have some functions that I'd like to use on every page. I guess this used to be done with App_Code, but that no longer seems to work in Core. How can I accomplish this in Asp.Net Core Razor Pages? 回答1: Option 1 - DI 1 - Create the service class with the relevant functionality public class FullNameService { public string GetFullName(string first, string last) { return $"{first} {last}"; } } 2- Register the service in startup services.AddTransient

aspnet-codegenerator: No code generators available, Even after adding Microsoft.VisualStudio.Web.CodeGeneration.Design

六月ゝ 毕业季﹏ 提交于 2020-12-08 13:37:41
问题 Unable to generate scaffolding using aspnet-codegenerator , below is what I tried: Created an ASP.Net RazorPages application using dotnet new webapp Did a dotnet build Installed dotnet-aspnet-codegenerator using dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4 Ran dotnet aspnet-codegenerator --help It says: No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference. Added the

aspnet-codegenerator: No code generators available, Even after adding Microsoft.VisualStudio.Web.CodeGeneration.Design

我是研究僧i 提交于 2020-12-08 13:27:31
问题 Unable to generate scaffolding using aspnet-codegenerator , below is what I tried: Created an ASP.Net RazorPages application using dotnet new webapp Did a dotnet build Installed dotnet-aspnet-codegenerator using dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4 Ran dotnet aspnet-codegenerator --help It says: No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference. Added the