ASP.Net MVC6 syntax for multiple checkbox form

Viewed 2097

I am building an ASP.NET MVC6 web application (ASP.net Core 1.0) and want a simple form which contains multiple checkboxes for a single property, allowing multiple selections. Lets say for argument's sake I want the user to check one or more checkboxes from a list of colours (Red, Blue, green, yellow etc).

I have three questions related to this...

1) What data type should the Colours property be in my view model (string, string[], bool[], List<String>, something else)? is SelectList still a valid thing in MVC6?

3) What is the correct syntax in my View for representing a list of checkboxes in the form? Should I be using the new Tag helpers feature here?

4) What should the input parameters be for my controller action? In asp.net 4.x it would be a FormCollection but not sure if that is still valid?

1 Answers
Related