I want my checkboxes in a form to return as a list of all the values for selected checkboxes
foreach (string url in ListOfPhotoURLs)
{
<div class="form-check form-check-inline">
<input asp-for="Input.ChosenPhotos" class="form-check-input" type="checkbox" id="PhotosChosen" value="@url">
<img src="@url" alt="photo from url @url" width="250">
<span class="text-danger" asp-validation-for="Input.ChosenPhotos"></span>
</div>
}
Where Input.ChosenPhotos
is type List<string>
and when the form is submitted I want my list to be populated with all of the values (url
) that correspond with a checked checkbox
When I run I get an error that basically says checkboxes can only return a bool or string. Not a list of strings or bools.
Problem is my list is of inderterminet length so I cant have an input model that has an individual property for each checkbox.
I'm not sure what the optimal solution is here?
Im using Razor Pages btw
Aucun commentaire:
Enregistrer un commentaire