Welcome to another AJAX tutorial, today we will be demonstrating how to use the MutuallyExclusiveCheckBox
extender.

The MutuallyExclusive CheckBox is an ASP.NET AJAX extender that can be attached to any ASP.NET CheckBox control. By adding a number of Checkboxes to the same “Key”, only one checkbox with the specified key can be checked at a time. This extender is useful when a number of choices are available but only one can be chosen, similar to a radio button.

The use of Checkboxes however allows you to choose to uncheck a value which is not normally possible with radio buttons.

Let’s build a simple form,

Lets begin by opening a new webform and we can go ahead and name it mutualcheckbox.aspx

Next up is adding the ScriptManager, we can drag and drop this onto our page

Now we can begin build our simple Checkbox form, really at this point you may set up your own check boxes with your own random questions,

What we did in this tutorial was

Added a PanelControl, and inside of it, we added a few checkboxes and attached some labels with some different food types.

Now lets add the MutuallyExclusiveCheckBox extender to the Checkboxes. The easiest way to do this is by clicking on the tab located to the right of the check boxes. This way the TargetControls are already assigned to each of the check boxes.

Now we can set the Keys to that of the Movie or Food for each CheckBox.

There you have it, it really is that simple to attach this control to some check boxes.

The markup code should look something like this:

As you can see when you load the page in the browser you get your options and what you wrote in your labels and checkboxes. You can select only one checkbox that matches the type first selected or what is associated with the original check box.

Download Source Files