ASP.NET MVC Checkbox Group

后端 未结 5 804
渐次进展
渐次进展 2020-12-29 10:36

I am trying to formulate a work-around for the lack of a \"checkbox group\" in ASP.NET MVC. The typical way to implement this is to have check boxes of the same name, each

5条回答
  •  太阳男子
    2020-12-29 11:05

    This solution may be of interest to those wanting a clean/simple approach: Maintain state of a dynamic list of checkboxes in ASP.NET MVC

    I wouldn't really recommend the use of Html.CheckBox unless you have a super simple, single checkbox bound to a single bool (or a couple of static ones at most). When you start having lists of checkboxes in a single array or dynamic checkboxes, it is difficult to work with and you end up programming the whole world in server side bloat just to deal with the shortfalls and get everything working. Forget it, and just use the clean HTML focused solution above and you're up and running quickly with less mess to maintain in the future.

提交回复
热议问题