如何使一个复选框列表的行为就像在Vb.net单选按钮? [英] How to make a CheckBox List behave like Radio Button in Vb.net?

查看:288
本文介绍了如何使一个复选框列表的行为就像在Vb.net单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我解释一下我做的VB.net asp.net应用程序,我想提出一个复选框列表,而不是单选按钮导致我的客户想要的方形和不是圆的。我得到的唯一的问题是,当我选中一个复选框,另一种是不选中。我不知道IM不够清晰随时问我问题。

Let me explain myself i'm doing an Application in VB.net asp.net and I Want to put a CheckBox List instead of Radio Button cause my customer want it square and not round. The Only problem i got is when i check a Checkbox the other one are not unchecked. I'm not sure im clear enough feel free to ask me question.

推荐答案

从以上可以看出,这是不推荐的。不过,如果你必须这样做,这里就是我jQuery中取得的:

As seen above, this isn't recommended. However if you have to do it, here's how I made it in jQuery:

创建复选框,并为它们分配类

Create your checkboxes and assign them classes

<input type="checkbox" class="cbr"/>CB 1
<input type="checkbox" class="cbr"/>CB 2
<input type="checkbox" class="cbr"/>CB 3
<input type="checkbox" class="cbr"/>CB 4
<input type="checkbox" class="cbr"/>CB 5

和jQuery的

$(".cbr").click(function() {
    $(".cbr").prop("checked", false);
    this.checked = true;
});

下面是一个演示: http://jsfiddle.net/g2YMs/

另外,如果你使用ASP.NET控件创建的复选​​框,应使用选择它们:

Also, if you're creating the checkboxes with ASP.NET controls, you should select them using:

$("#<%=IdOfControl.ClientID%>")

这是当然,如​​果你决定去jQuery的方式。

This is, of course, if you decide to go the jQuery way.

这篇关于如何使一个复选框列表的行为就像在Vb.net单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆