MutuallyExclusiveCheckBoxExtender控件用于对一个项目进行选择,使它只可以选一个,但是若不可能发生,也可以不选择。
下面请看一个示例:

1)在VS2005中新建一个ASP.NET AJAX-Enabled Web Project项目工程,命名为MutuallyExculsiveCheckBoxExtender1。

2)在页面上拖放4个CheckBox,分别设置它们的ID为CheckBox1,CheckBox2,CheckBox3,CheckBox4,设置文本为bedroom,bedroom,door,door。

代码如下:

 1AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <br />
 2AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        Do &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 3AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 4AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Don't<br />
 5AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <br />
 6AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <asp:CheckBox ID="CheckBox1" Text="bedroom" runat="server" />
 7AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 8AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
 9AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <asp:CheckBox ID="CheckBox2" Text="bedroom" runat="server" />
10AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <br />
11AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <br />
12AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <asp:CheckBox ID="CheckBox3" runat="server" Text="door" />
13AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
14AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
15AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <asp:CheckBox ID="CheckBox4" runat="server" Text="door" /><br />
16AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <br />

3)然后在页面上拖放4个MutuallyExculsiveCheckBoxExtender控件,分别关联到CheckBox1,CheckBox2,CheckBox3,CheckBox4。并设置一些属性。

代码如下:

 1AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <cc1:MutuallyExclusiveCheckBoxExtender ID="MutuallyExclusiveCheckBoxExtender1" TargetControlID="CheckBox1" Key="bedroomCheckBox" runat="server">
 2AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        </cc1:MutuallyExclusiveCheckBoxExtender>
 3AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 4AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 5AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        &nbsp; &nbsp; &nbsp; &nbsp;
 6AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <cc1:MutuallyExclusiveCheckBoxExtender ID="MutuallyExclusiveCheckBoxExtender2" TargetControlID="CheckBox2" Key="bedroomCheckBox" runat="server">
 7AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        </cc1:MutuallyExclusiveCheckBoxExtender>
 8AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <br />
 9AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <cc1:MutuallyExclusiveCheckBoxExtender ID="MutuallyExclusiveCheckBoxExtender3" TargetControlID="CheckBox3" Key="doorCheckBox" runat="server">
10AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        </cc1:MutuallyExclusiveCheckBoxExtender>
11AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <br />
12AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        <cc1:MutuallyExclusiveCheckBoxExtender ID="MutuallyExclusiveCheckBoxExtender4" TargetControlID="CheckBox4" Key="doorCheckBox" runat="server">
13AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)        </cc1:MutuallyExclusiveCheckBoxExtender>

属性说明:
      TargetControlID:该控件关联的CheckBox。
      Key:这唯一的键用于关联几个CheckBox,从而使这几个CheckBox最多只能有一个选择或不选。

4)按下CTRL+F5,在浏览器中查看该效果。

该效果图如下:

AJAX ControlToolkit学习日志-MutuallyExclusiveCheckBoxExtender(17)

相关文章:

  • 2021-07-30
  • 2021-05-18
  • 2021-10-30
  • 2021-12-30
  • 2021-10-30
  • 2022-02-20
  • 2022-01-04
  • 2021-12-09
猜你喜欢
  • 2021-06-22
  • 2021-08-20
  • 2021-10-30
  • 2022-01-04
  • 2021-12-04
  • 2022-03-06
  • 2021-09-20
相关资源
相似解决方案