ClientIds for individual CheckBoxes in a CheckBoxList

Discussion in 'ASP .Net' started by Nathan Sokalski, Apr 3, 2009.

  1. I am generating JavaScript that needs to reference the checkboxes rendered
    by a CheckBoxList. How can i get the ClientIds for the checkboxes rendered
    by a CheckBoxList? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Apr 3, 2009
    #1
    1. Advertising

  2. Nathan Sokalski

    imransyed63

    Joined:
    May 16, 2006
    Messages:
    27
    var chkListId = '<%=CheckBoxList1.ClientID%>';
    var idCollection = new Array();
    var items = document.getElementsByTagName("INPUT");
    for (var i=0;i<items.length;i++)
    {
    if (items.type.toLowerCase() == 'checkbox' && items.id.indexOf(chkListId)>=0 )
    {
    idCollection.push(items.id);
    }
    }

    // idCollection will give you the list of Checbox ids.
    imransyed63, Apr 5, 2009
    #2
    1. Advertising

  3. You should be able to easily acheive this by accessing the input elements
    in side the CheckBoxList.
    I actually did a BlogPost with sample code that exactly does this here
    http://ctrlf5.net/?p=33.

    Hope this helps
    --

    Thank You,
    Nanda Lella,
    http://www.ctrlf5.net
    This Posting is provided "AS IS" with no warranties, and confers no rights.
    Nanda Lella[MSFT], Apr 23, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric Robishaw
    Replies:
    1
    Views:
    4,324
    Victor Garcia Aprea [MVP]
    Dec 27, 2003
  2. =?Utf-8?B?UnlhbiBTY3VsbHk=?=

    CheckBoxList Individual Item Detection

    =?Utf-8?B?UnlhbiBTY3VsbHk=?=, Jun 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,963
    avnrao
    Jun 23, 2004
  3. Ratman
    Replies:
    2
    Views:
    1,529
    Ratman
    Jul 4, 2004
  4. TS
    Replies:
    5
    Views:
    693
    Jeffrey Tan[MSFT]
    Aug 10, 2005
  5. Nathan Sokalski

    ClientIds for individual CheckBoxes in a CheckBoxList

    Nathan Sokalski, Apr 3, 2009, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    891
    Nanda Lella[MSFT]
    Apr 29, 2009
Loading...

Share This Page