I try to use the following expemple of Input Tag Helper in my code, but it isn´t working. https://docs.microsoft.com/de-de/aspnet/core/mvc/views/working-with-forms?view=aspnetcore-2.2 https://www.learnrazorpages.com/razor-pages/tag-helpers/input-tag-helper
I want to use a list of objects to display in a table and read there values from inputs. Display the data works, but not reading the Inputs.
cshtml
@page
@{
var days2 = @Model.days;
}
<form class="form-horizontal" method="post">
<button asp-page-handler="Go" type="submit" class="btn btn-default">Go</button>
<table class="table">
<thead>
<tr>
<th>@Html.DisplayNameFor(m => m.days[0].Name)</th>
<th>@Html.DisplayNameFor(m => m.days[0].Beginn)</th>
........
</tr>
</thead>
<tbody>
@for (int i =0; i< days2.Count; i++)
{
<tr>
<td><input asp-for="@days2[i].Name" class="form-control" value=Tag.Name /></td>
<td><input asp-for="@days2[i].Beginn" class="form-control" value=Tag.Beginn /></td>
.....
</tr>
}
</tbody>
</table>
</form>
cshtml.cs
[BindProperty]
public List<day> days { get; set; }
public void OnGet()
{
days=getdaysvalue();
}
public void OnPostGo()
{
for (int i = 0; i < Tage.Count; i++)
{
days[i].Name = days2[i].Name; //days2 is in the actuell context not given
days[i].Beginn = days2[i].Beginn;
}
days2 is in the actuell context not given
Tage
and what is the purpose forvar days2 = @Model.days;
? – Edward