Click here to Skip to main content
13,358,079 members (58,552 online)
Click here to Skip to main content
Add your own
alternative version


1 bookmarked
Posted 3 Jan 2013

CheckBoxList acts like RadioButtonList

, 3 Jan 2013
Rate this:
Please Sign up or sign in to vote.
Checkboxes working like radio buttons.


This article is about how to use CheckBoxList to work like RadioButtons using JavaScript.

Using the code

Just place the code given below in the head section of your .ASPX page:

<script type="text/javascript" language="javascript">
    function SetChkBx(event) {
        var chkBoxCount = document.getElementById('<%= chkList1.ClientID %>').getElementsByTagName("input");
        for (i = 0; i < chkBoxCount.length; i++) {
            if (chkBoxCount[i].type == 'checkbox')
                chkBoxCount[i].checked = false;
        if ( == null) {
            event.srcElement.checked = true;
            alert("You selected " + event.srcElement.value);
        else {
   = true;
            alert("You selected " +;

Points of Interest 

Here is the code, is used which is always null for IExplorer. event.srcElement is used in IExplorer which tell the browser about the source element and and is not null for other browsers. So for other browsers we we use this.

Place the below tag under your <Form> tag.

<asp:CheckBoxList ID="chkList1" runat="server" RepeatDirection="Vertical" 

    RepeatLayout="Flow" OnClick="javascript:SetChkBx(event);">


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Agrawal Ashok
Software Developer (Junior)
India India
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 3 Pin
sandeepkumarvemula11-Feb-13 23:28
membersandeepkumarvemula11-Feb-13 23:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 3 Jan 2013
Article Copyright 2013 by Agrawal Ashok
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid