I’m writing a “Course” application in ASP.NET Core MVC. When I try to apply any course, it returns no value for SelectedCourse
. I tried
<input id "mvc1" type="radio" asp-for="SelectedCourse"value="ASP.NET Core MVC" checked="true" />
but it didn’t work.
Apply.cshtml
:
<div>
<fieldset></fieldset>
<legend>Select One(1) Course</legend>
<p>
<input id "mvc1" type="radio" asp-for="SelectedCourse"value="ASP.NET Core MVC" checked="true" />
<label>ASP.NET Core MVC</label>
</p>
<p>
<input id "mvc2" type="radio" asp-for="SelectedCourse" value="Blazor" />
<label>Blazor</label>
</p>
<p>
<input id "mvc3" type="radio" asp-for="SelectedCourse"value="API" />
<label>Api</label>
</p>
</div>
Repository.cs
:
namespace BTK_Akademi.Models
{
public static class Repository
{
private static List<Candidate> applications = new();
//Listenin dışardan düzenlenmemesi lazım yani readonly olacak
public static IEnumerable<Candidate> Applications => applications;
public static void Add(Candidate candidate)
{
applications.Add(candidate);
}
}
}