实例:
任何时候只有一个复选框被选中
<b>选中</b><br />
<asp:Checkbox runat="server" ID="c1" Text="选择" />
<ajaxToolkit:MutuallyExclusiveCheckboxExtender runat="server" ID="m1" TargetControlID="c1" Key="CB" />
<b>不选中</b><br />
<asp:Checkbox runat="server" id="c2" Text="反选" />
<ajaxToolkit:MutuallyExclusiveCheckboxExtender ID="m2" runat="server" TargetControlID="c2" Key="CB" />
<shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></path><lock aspectratio="t" v:ext="edit"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 96pt; HEIGHT: 53.25pt" type="#_x0000_t75"><imagedata o:title="" src="file:///C:%5CDOCUME~1%5CADMINI~1%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image001.png"></imagedata></shape>
<shape id="_x0000_i1026" style="WIDTH: 96.75pt; HEIGHT: 51.75pt" type="#_x0000_t75"><imagedata o:title="" src="file:///C:%5CDOCUME~1%5CADMINI~1%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image003.png"></imagedata></shape>
属性 |
解释 |
TargetControlID |
目标控件 |
Key |
同一个key为同一组关联复选框 |
三个复选框也是一样,只能有一个被选中。
效果如下
<shape id="_x0000_i1027" style="WIDTH: 139.5pt; HEIGHT: 74.25pt" type="#_x0000_t75"><imagedata o:title="" src="file:///C:%5CDOCUME~1%5CADMINI~1%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image005.png"></imagedata></shape>
1
<asp:Checkbox runat="server" ID="c1" Text="选1" />
<ajaxToolkit:MutuallyExclusiveCheckboxExtender runat="server" ID="m1"
TargetControlID="c1"
Key="CB" />
2
<asp:Checkbox runat="server" id="c2" Text="选2" />
<ajaxToolkit:MutuallyExclusiveCheckboxExtender ID="m2" runat="server" TargetControlID="c2"
Key="CB" />
3
<asp:Checkbox runat="server" id="c3" Text="选3" />
<ajaxToolkit:MutuallyExclusiveCheckboxExtender ID="m3" runat="server" TargetControlID="c3"
Key="CB" />
http://asp.net/AJAX/Control-Toolkit/Live/MutuallyExclusiveCheckBox/MutuallyExclusiveCheckBox.aspx