4

I have a Model that has a enum property with the Flags attribute.

[Flags]
public enum MyEnumType
{
    None,
    Standard = 1,
    Extra = 2,
    Special = 4
}

public class MyModel
{
    public MyEnumType Value { get; set; }
}

In the html form I have this edited with checkboxes:

<input name="Value" type="checkbox" value="Standard"/>
<input name="Value" type="checkbox" value="Extra"/>
<input name="Value" type="checkbox" value="Special"/>

In the post body there can be multiple values for Value now. But how can I make a ModelBinder that automatically binds these to my flags-enum?

Jacco
  • 370
  • 1
  • 14
  • See https://www.stackoverflow.com/questions/31415326/using-checkboxes-to-postback-enum-with-flags#31415894. – user2609980 Jul 14 '15 at 19:51
  • Possible duplicate of [Using checkboxes to PostBack Enum with Flags](https://stackoverflow.com/questions/31415326/using-checkboxes-to-postback-enum-with-flags) – superjos Jan 12 '18 at 14:58

0 Answers0