jQuery: check all checkboxes

Posted by pcampbell on Stack Overflow See other posts from Stack Overflow or by pcampbell
Published on 2010-01-18T18:56:59Z Indexed on 2010/03/24 4:03 UTC
Read the original article Hit count: 443

Filed under:
|

Consider this scenario:

  • <asp:CheckBoxList> in a master page.
  • the goal is to have all checkboxes in this list to be checked on page load.
  • there are many checkbox lists on the page.

The markup:

    <asp:CheckBoxList runat="server" ID="chkSubscriptionType" 
        DataSourceID="myDS"
        CssClass="boxes" DataTextField="Name" DataValueField="Name"  />

renders to:

<input id="ctl00_cphContent_chkSubscriptionType_0" type="checkbox" name="ctl00$cphContent$chkSubscriptionType$0" />

Question: how can you use jQuery to check all boxes in this asp:CheckBoxList on document.ready? I see samples everywhere, but naming convention used by the master page throws off the samples in other places.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about jQuery