473,800 Members | 3,056 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Any way to make a CheckBoxList behave like a RadioButton?

I have a CheckBoxList that under some circumstances I want to only allow
one selection, so that if you select a different item, whatever was
selected before becomes un-selected.
Any ideas on how to do this?

Ideas, and even better, examples would be appreciated!

Matt
Nov 19 '05 #1
4 6544
Hi Matt,

I'd use a javascript to do this, but it only works when the
RepeatLayout property is set to Flow.

On mouse-click, it resets all checkboxes in the list to unchecked, and
then checks the current item.

Here's how the CheckBoxList control should look like:

<asp:CheckBoxLi st id="CheckBoxLis t1" runat="server" RepeatLayout="F low"
onclick="try{if (event.srcEleme nt.type=='check box'){var
nodes=event.src Element.parentN ode.childNodes; for(i=0,numberO fElements=child Nodes.length;i< numberOfElement s;++i)if(childN odes[i].type=='checkbo x')childNodes[i].checked='';}ev ent.srcElement. checked='checke d';}catch(E){}" >

Alternatively, you could consider using the RadioButtonList .

Nov 19 '05 #2
Collin Chung wrote:
Hi Matt,

I'd use a javascript to do this, but it only works when the
RepeatLayout property is set to Flow.

On mouse-click, it resets all checkboxes in the list to unchecked, and
then checks the current item.

Here's how the CheckBoxList control should look like:

<asp:CheckBoxLi st id="CheckBoxLis t1" runat="server" RepeatLayout="F low"
onclick="try{if (event.srcEleme nt.type=='check box'){var
nodes=event.src Element.parentN ode.childNodes; for(i=0,numberO fElements=child Nodes.length;i< numberOfElement s;++i)if(childN odes[i].type=='checkbo x')childNodes[i].checked='';}ev ent.srcElement. checked='checke d';}catch(E){}" >

Alternatively, you could consider using the RadioButtonList .


Thanks. I'll give it a shot.
I want to use the CheckBoxList instead of a RadioButtonList because in
many cases the user is allowed to make multiple selections. I thought
that keeping one kind of control and changing the behavior would be a
more consistent interface.

Matt
Nov 19 '05 #3
>I want to use the CheckBoxList instead of a RadioButtonList because in
many cases the user is allowed to make multiple selections. I thought
that keeping one kind of control and changing the behavior would be a
more consistent interface.


Actually, you will confuse the user far more by doing this than you
would if you changed the controls to radio buttons.

User subconsciously expect things to work a certain way, and if you try
and change the behaviour of standard elements, you will confuse users.
At the least, this will cause them to have to stop and think when trying
to use your site, at worst, you will confuse them enough that they will
give up and go elsewhere.

Don't underestimate this point, it is a very strong one that most people
miss. If you sit and watch non-web designers trying to use most web
sites that exist, you will be amazed at how much they struggle with poor
design choices like this.

See www.useit.com for the opinions of the web's #1 guru on usability
issues. He speaks a lot about the dangers of changing expected
behaviour.

HTH

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #4
Alan Silver wrote:
I want to use the CheckBoxList instead of a RadioButtonList because in
many cases the user is allowed to make multiple selections. I thought
that keeping one kind of control and changing the behavior would be a
more consistent interface.

Actually, you will confuse the user far more by doing this than you
would if you changed the controls to radio buttons.

User subconsciously expect things to work a certain way, and if you try
and change the behaviour of standard elements, you will confuse users.
At the least, this will cause them to have to stop and think when trying
to use your site, at worst, you will confuse them enough that they will
give up and go elsewhere.

Don't underestimate this point, it is a very strong one that most people
miss. If you sit and watch non-web designers trying to use most web
sites that exist, you will be amazed at how much they struggle with poor
design choices like this.

See www.useit.com for the opinions of the web's #1 guru on usability
issues. He speaks a lot about the dangers of changing expected behaviour.

HTH


Well I decided against it before seeing your reply, but this affirms my
decision.

Thanks for the input!

Matt
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2852
by: VK | last post by:
Hi! What I'm missing in following code? Cannot get the values of radiobuttons. Starting only one class (GetVariant), it works. When I put two classes together, it doesn't. Regards, VK from Tkinter import * class GetVariant: def __init__(self): self.root = Tk()
0
7950
by: Bryce Budd | last post by:
Hello All, I've been a taker of information from newsgroups for a long time and thought I'd finally make a contribution back to the community whose supported me when I've needed it. After all before commercialization took over that was the beauty of the Internet! I've create a checkboxlist validator control...something MS should have done originally in my opinion, but nonetheless here it is. It's a C# control, sort of IE specific. ...
4
8073
by: dm_dal | last post by:
Is there a know issue surrounding the CheckBoxList control and it's viewstate? When my control is created, it's ListItems are checked as needed, but on a postback, they loose their Selected status. David
4
6532
by: Shaul Feldman | last post by:
Hello, I have something really awkward at work - fighting with CheckBoxList... How can I define CSS for ListItem in CheckBoxList programmatically. I add CheckBoxList's Items on the fly, something like dim li as ListItem li = new ListItem("title","value"); '' how to define here the CSS for List Item, not CheckBoxList?!?!?! myCheckBoxList.Items(x).add(li);
1
2389
by: Empire City | last post by:
I have an ASP.NET form with a DataGrid and Button. I want to put a RadioButtonList in a DataGrid cell. I bind it to an ArrayList which has a ListItem in the cell. The display part works fine. I then check some boxes and hit the submit button. I can't seem to get the value that is selected on the RadioButton List. I don't want to use the EditTemplate thing I just want to click on the radiobutton and submit the form. I also don't want to do...
5
13394
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able to get a Boolean value TRUE or FALSE when a checkBox is selected. When the checkBoxList was out of the DataList i used "OnSelectedIndexChanged" and it was returning what i wanted but if its in a
4
4043
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to work:( Thanks My CheckBoxList in the DataList Below
2
407
by: jase_rw | last post by:
Hi There, Having trouble with a CheckBoxList in VB.NET. I've a CheckBoxList on a webform. I read some data from a database and try and check the appropriate boxes based on the data. Unfortunately, the CheckBoxList seems to behave like a RadioButtonList and only leaves the last item checked. I've even tried just to hard code 2 boxes being checked and that just
4
3117
by: adiweb | last post by:
I would like to use a radiobuttonlist in a windows form control but I know this is not possible because radiobuttonlists are only available in web forms. I am trying to use a checkboxlist instead and I am encountering problems. I do not want multiple checks. Any help is highly appreciated.
0
10495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10269
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2942
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.