Terry's blog

Focus on bigdata and cloud.

博客园 首页 新随笔 联系 订阅 管理
功能:
    可以应用到页面中的CheckBox上,通过为一组CheckBox指定同样的Key,让它们拥有类似单选按钮组(Radio Button Group)的行为,即用户只能选择组中的某一项。与单选按钮组不同的是,这个由CheckBox组成的单选按钮允许取消选择,即不选择组中的任意一项,而传统的单选按钮组则无法实现这个功能。

属性:
     Key:隶属于同一群组的复选框,必须具有独一的键值。
     TargetControlID:目标控件ID值。
实例代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    
<title>Untitled Page</title>
</head>
<body>
    
<form id="form1" runat="server">
     
<asp:ScriptManager ID="sm" runat="server" />
         
<table>
                
<tr>
                  
<td colspan="2" >
                    外出旅游,您会携带‧‧‧
                  
</td>
                
</tr>
                
<tr>
                  
<td style="width: 165px" >
                    会携带
                  
</td>
                  
<td style="width: 165px" >
                    不会携带
                  
</td>
                
</tr>
                
<tr>
                  
<td>
                    
<asp:CheckBox ID="chkBoxTakeCellPhone" runat="server" Text="手机" /><br />
                    
<asp:CheckBox ID="chkBoxTakeCamera" runat="server" Text="相机" /><br />
                    
<asp:CheckBox ID="chkBoxTakeMP3" runat="server" Text="MP3" /><br />
                    
<asp:CheckBox ID="chkBoxTakeEraset" runat="server" Text="耳机" /><br />
                    
<asp:CheckBox ID="chkBoxTakeNB" runat="server" Text="笔记本" /><br />
                    
<asp:CheckBox ID="chkBoxTakeFlashDrive" runat="server" Text="随身听" /><br />
                  
</td>
                  
<td>
                    
<asp:CheckBox ID="chkBoxNotTakeCellPhone" runat="server" Text="手机" /><br />
                    
<asp:CheckBox ID="chkBoxNotTakeCamera" runat="server" Text="相机" /><br />
                    
<asp:CheckBox ID="chkBoxNotTakeMP3" runat="server" Text="MP3" /><br />
                    
<asp:CheckBox ID="chkBoxNotTakeEraset" runat="server" Text="耳机" /><br />
                    
<asp:CheckBox ID="chkBoxNotTakeNB" runat="server" Text="笔记本" /><br />
                    
<asp:CheckBox ID="chkBoxNotTakeFlashDrive" runat="server" Text="随身听" />
                    
<br />
                  
</td>
                
</tr>
                
<tr>
                  
<td colspan="2">
                    
<hr />
                  
</td>
                
</tr>              
              
</table>
               
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeTakeCellPhone"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxTakeCellPhone"
                                                             Key
="CellPhone">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>
              
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeNotTakeCellPhone"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxNotTakeCellPhone"
                                                             Key
="CellPhone">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>

              
<%-- 设定「相机」的互斥式复选框 --%>
              
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeTakeCamera"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxTakeCamera"
                                                             Key
="PDA">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>
              
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeNotTakePDA"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxNotTakeCamera"
                                                             Key
="PDA">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>

              
<%-- 设定「MP3」的互斥式复选框 --%>
              
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeTakeMP3"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxTakeMP3"
                                                             Key
="MP3">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>
              
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeNotTakeMP3"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxNotTakeMP3"
                                                             Key
="MP3">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>

              
<%-- 设定「耳机」的互斥式复选框 --%>
              
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeTakeEarset"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxTakeEraset"
                                                             Key
="Eraset">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>
              
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeNotTakeEarset"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxNotTakeEraset"
                                                             Key
="Eraset">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>

              
<%-- 设定「笔记本」的互斥式复选框 --%>
              
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeTakeNB"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxTakeNB"
                                                             Key
="NB">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>
              
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeNotTakeNB"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxNotTakeNB"
                                                             Key
="NB">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>

              
              
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeTakeFlashDrive"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxTakeFlashDrive"
                                                             Key
="FlashDrive">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>
              
<ajaxToolkit:MutuallyExclusiveCheckBoxExtender ID="mecbeNotTakeFlashDrive"
                                                             runat
="server"
                                                             TargetControlID
="chkBoxNotTakeFlashDrive"
                                                             Key
="FlashDrive">
              
</ajaxToolkit:MutuallyExclusiveCheckBoxExtender>
    
</form>
</body>
</html>

运行结果:
    
posted on 2007-11-05 18:13  王晓成  阅读(379)  评论(0编辑  收藏  举报