In this article I will explain a simple tutorial with an example, how to implement ASP.Net AJAX MutuallyExclusiveCheckBoxExtender control of the ASP.Net Ajax Control Toolkit Library using C# and VB.Net.
The ASP.Net AJAX MutuallyExclusiveCheckBoxExtender control is used to make a group of CheckBoxes mutually exclusive i.e. if you select one CheckBox other will be unchecked. In simple words to make it work similar to how a single choice RadioButtons work.
Using the ASP.Net Ajax Control ToolKit MutuallyExclusiveCheckBoxExtender Control
1. Register the AJAX Control Toolkit Library after adding reference to your project.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
2. Drag an ASP.Net AJAX ToolkitScriptManager on the page.
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
3. Then you need to add the ASP.Net AJAX MutuallyExclusiveCheckBoxExtender control next to each CheckBox control which you want to make mutually exclusive.
There are two important properties:
1. TargetControlID – ID of the CheckBox to which the ASP.Net AJAX MutuallyExclusiveCheckBoxExtender control is associated.
2. Key – The Key value must be same for all the ASP.Net AJAX MutuallyExclusiveCheckBoxExtender controls so that they work in mutually exclusive fashion.
<asp:CheckBox ID = "chkMango" Text="Mango" runat="server" /><br />
<asp:MutuallyExclusiveCheckBoxExtender ID="meceMango" runat="server" TargetControlID = "chkMango" Key = "Fruit">
<asp:CheckBox ID = "chkApple" Text="Apple" runat="server" /><br />
<asp:MutuallyExclusiveCheckBoxExtender ID="meceApple" runat="server" TargetControlID = "chkApple" Key = "Fruit">
<asp:CheckBox ID = "chkBanana" Text="Banana" runat="server" /><br />
<asp:MutuallyExclusiveCheckBoxExtender ID="meceBanana" runat="server" TargetControlID = "chkBanana" Key = "Fruit">
<asp:CheckBox ID = "chkGuava" Text="Guava" runat="server" /><br />
<asp:MutuallyExclusiveCheckBoxExtender ID="meceGuava" runat="server" TargetControlID = "chkGuava" Key = "Fruit">
<asp:CheckBox ID = "chkOrange" Text="Orange" runat="server" /><br />
<asp:MutuallyExclusiveCheckBoxExtender ID="meceOrange" runat="server" TargetControlID = "chkOrange" Key = "Fruit">
Ajax Control ToolKit MutuallyExclusiveCheckBoxExtender Tutorial with example in ASP.Net