mardi 28 avril 2015

Javascript to loop through asp checkboxes to see if any are checked

I am having an issue looping though asp checkboxes in an ascx file to see each individual element's "state" (checked or not). Here is my code:

<asp:ListView runat="server" ID="lvApplicationForms" OnItemCommand="lvAttachedDocuments_OnItemCommand"
    DataKeyNames="FormID" OnPreRender="lvApplicationForms_PreRender" OnItemDataBound="lvApplicationForms_ItemDataBound">
    <ItemTemplate>
        <tr class="<%# (Container.DisplayIndex + 1 )% 2 == 0 ? "EvenRow" : "OddRow" %>" data-formname='<%#Eval("FormName")%>'>
            <td class="fieldName_td" style="text-align: center">
                <asp:CheckBox ID="cbIsExposed" runat="server" Style="text-align: center" onclick="javascript:return CheckedChange(this)" OnChecked='<%# Eval("IsPublished") %>'
                    Enabled='<%# CanCounterSignAndExpose && Convert.ToBoolean(Eval("CanBePublished")) %>' />
            </td>
            </tr>
    </ItemTemplate>
    </asp:ListView>

Essentially my issue is that I have a save button on the page that I want enabled only if at least one element in the checkboxes is checked. If none are, keep the save button disabled. I know how to disable the save button, I just don't know how to loop though the checkboxes to get their "state".




Aucun commentaire:

Enregistrer un commentaire