Mutual Exclusive CheckBoxes 

This control needs reference to MVCControlToolkit.Controls.Core-x.x.x.js.

Mutual Exclusive Checkboxes are useful when you cannot use  radio buttons(or option buttons...call it as you prefer). Option buttons are required to have all the same name, and the value returned to the server is the value of the only option button selected. If you need boolean values, instead, mutual exclusive check boxes do allows only one option be selected as the option buttons but you have a set of boolean values. 

Using them is easy. Just insert your checkboxes as you want, but let the checkboxes that need to be mutual exclusive share a common css class, then call the MutualExclusiveChoice helper passing it the name of the previous css class! That's all! the check boxes will be transformed into mutual exclusive check boxes.

Below an example:

 

<div>
   <input id="Checkbox1" type="checkbox" class="display-field, couple" checked="checked" />
   <input id="Checkbox2" type="checkbox" class="display-field, couple" />
   <input id="Checkbox3" type="checkbox" class="display-field, couple" />
   <input id="Checkbox4" type="checkbox" class="display-field, couple" />
   @Html.MutualExclusiveChoice("couple")
</div>

Last edited Jun 22, 2014 at 10:57 AM by frankabbruzzese, version 16

Comments

No comments yet.